S.O.S. Mathematics CyberBoard

Your Resource for mathematics help on the web!
It is currently Thu, 23 May 2013 18:42:49 UTC

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: iomanip
PostPosted: Wed, 29 Jun 2005 09:38:38 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame

Joined: Wed, 21 May 2003 10:00:57 UTC
Posts: 377
Location: Australia
Hi,

I don't understand how this code:

cout << setfill('#') << setw(5) << "a" << "b" << "c" << endl;

produces this:

####abc

:?:


Top
 Profile  
 
 Post subject:
PostPosted: Wed, 29 Jun 2005 09:56:56 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame
User avatar

Joined: Wed, 1 Oct 2003 04:45:43 UTC
Posts: 9633
Hi novice,

cout << setfill('#') << setw(5)
. . . sets the fill character to '#' and the field width to 5. No output at this point.

<< "a"
. . . inserts an 'a' into a field of width 5. The remaining four characters in the field will become fill symbols (in this case, the '#' symbol). Now the output is: ####a

<< "b" << "c" << endl;
. . . concatenates "bc" at the end of the output, and terminates the current line. Final output: ####abc


Top
 Profile  
 
 Post subject:
PostPosted: Wed, 29 Jun 2005 10:31:14 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame

Joined: Wed, 21 May 2003 10:00:57 UTC
Posts: 377
Location: Australia
Thanks! :D

I was thinking the "bc" is part of the field..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Contact Us | S.O.S. Mathematics Homepage
Privacy Statement | Search the "old" CyberBoard

users online during the last hour
Powered by phpBB © 2001, 2005-2011 phpBB Group.
Copyright © 1999-2013 MathMedics, LLC. All rights reserved.
Math Medics, LLC. - P.O. Box 12395 - El Paso TX 79913 - USA