iomanip setw() and std::string

R

[rob desbois]

Hi all,

I've just discovered that when outputting a string in combination with
the I/O manipulator setw(n), it doesn't affect the string. Instead the
string's c_str() method must be called for setw() to work.

I initially thought it was a bug in my implementation, but apparently
not.
Can anyone inform me why this is?

TIA,
--rob
 
J

James Kanze

I've just discovered that when outputting a string in combination with
the I/O manipulator setw(n), it doesn't affect the string. Instead the
string's c_str() method must be called for setw() to work.
I initially thought it was a bug in my implementation, but
apparently not. Can anyone inform me why this is?

Sounds like a bug to me. The insertion operator on an
std::string is required to take the width into account, and
always has been. And it works with all of the implementations
of the library I have available here (g++, Roguewave and
STLport).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top