Wednesday 25 July 2012

iomanip library

<iomanip>

Defines manipulators for formatted output of numeric types. They have no effect on strings. setw() applies only to the next object printed, but the others remain in effect until changed.
out << setw(i); // Pad next output to i chars, then back to 0
out << setfill(c); // Pad with c (default ' ')
out << setprecision(i); // Use i significant digits for all float, double

cout << setw(6) << setprecision(3) << setfill('0') << 3.1; // print "003.10"

No comments:

Post a Comment