Formatting Output
- the C++ i/o library provides a number of utility functions
- #include <iomanip>
- setw (int)
- For non character data (strings, int, float)
- Controls the width of the output field
- Describes the minimum number of characters to be printed
- For Right Justified output
- cout << setw(7);
- This will cause the next item output to be at least
seven spaces wide, padded with blank spaces if necessairy.
- fixed, scientific
- All floating point output is in (fixed, scientific) format
- cout << fixed;
- Until changed
- showpoint, noshowpoint - floats print with decimal point showing.
- setprecision (n) - n is the number of decimal places to show.
- Note : these will not work on cslab103, but will work on the
new slackware distributions (on the laptop)