cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
ios::width vs.< iomanip> setw()
ios::width vs.< iomanip> setw()
Jan 29, 2012 at 7:21pm UTC
pxm76
(2)
I wanted to know if when formatting output if there is a preference between iso::width from the <iostream> header and setw() in the <iomanip> header? If there is a preference or reason to use one over the other please explain why.
Thanks in advance,
pxm76
Jan 29, 2012 at 9:08pm UTC
JLBorges
(13770)
If multiple output values are to be formatted, each with its own width, using the manipulator makes the code more readable.
cout << setw(25) << name << setw(12) << phone << setw(4) << age <<
'\n'
;
Jan 29, 2012 at 9:11pm UTC
pxm76
(2)
That makes sense. Thanks for the reply!
Topic archived. No new replies allowed.