www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - iomanipulator setw ( )

↑ ↓ ← "Graydon Ekdahl, Ph. D." <gekdahl bellsouth.net> writes:
I have not done much with C++ for several years and was surprised to
discover that setw ( ) does not work as expected in DM C++ and in Gnu
g++.

cout << '[' << setw ( 10 ) << 'X' << ']' << endl;

In Watcom C++ 11.c and in Borland C++ 5.02 the result is:
[          X].

In GNU g++ version about 2.8, I think, and in DMar C++ the result is:
[X].

I have tried a couple of things such as "use namespace std;" and
changing includes from #include <iomanip.h> to #include <iomanip> and
have removed setw ( ) and used cout.width ( ) with some changes in the
code to accommodate but with no success.

Does anyone know why the various compilers behave differently?  What did
I miss?

Thank you for any help.

Graydon Ekdahl
Jun 21 2002
↑ ↓ → "Laurentiu Pancescu" <user invalid.domain> writes:
I think the behaviour you expect is correct.  The '[        X]' is also the
result you get from gcc-2.95.3 with STLport-4.5.3, but unfortunately not
without it.  MSVC6 also displays that.

If you are interested in ISO-C++ compliance, I suggest gcc-2.95.3 (MinGW or
Cygwin) w/ STLport, or Comeau - they are the best!  Unfortunately, DMC is
very much behind standard compliance...


Laurentiu


"Graydon Ekdahl, Ph. D." <gekdahl bellsouth.net> wrote in message
news:3D13A06D.F17C92F4 bellsouth.net...
 I have not done much with C++ for several years and was surprised to
 discover that setw ( ) does not work as expected in DM C++ and in Gnu
 g++.

 cout << '[' << setw ( 10 ) << 'X' << ']' << endl;

 In Watcom C++ 11.c and in Borland C++ 5.02 the result is:
 [          X].

 In GNU g++ version about 2.8, I think, and in DMar C++ the result is:
 [X].

 I have tried a couple of things such as "use namespace std;" and
 changing includes from #include <iomanip.h> to #include <iomanip> and
 have removed setw ( ) and used cout.width ( ) with some changes in the
 code to accommodate but with no success.

 Does anyone know why the various compilers behave differently?  What did
 I miss?

 Thank you for any help.

 Graydon Ekdahl

Jun 25 2002