iomanip.h (see iostream.h)
Symbols Defined: setw, setprecision, setiosflags, resetiosflags, setfill, hex, oct, dec, ios::left, ios::scientific, ios::fixed, ios::right, ios::in, ios::out, ios::beg, ios::cur, ios::end
Usage: cout<<hex<<58<<oct<<58<< dec<<58;
Output: 3a 72 58
| hex | causes the numbers that follow to be printed in hexadecimal using the digits 0-9 and a-f. Once set, a number-base manipulator remains in effect until overridden by another manipulator. |
| oct | causes the numbers that follow to be printed in octal using the digits 0-7. |
| dec (the default setting) | causes the numbers that follow to be printed in decimal using the digits 0-9. |
Usage: cout<<setiosflags(ios::left)<<setw(10)<<56<<setw(10)<<82<<endl;
| Output: | 56 | 82 |
Usage: cout<<setiosflags(ios::right)<<setw(10)<<56<<setw(10)<<82<<endl;
| Output: | 56 | 82 |
| setw(8) (the default is 0) | sets the width of the space in which the next number is output. If the width is zero, only the number is output with no leading or trailing blanks. |
| setiosflags(ios::left|ios::fixed) | the flags are named ios::left etc. Flags may be combined as in setiosflags(ios::left|ios::fixed). Once set, the effect of a flag remains active until a reset or a different flag is set. |
| ios::left | only affects the next number printed. It will be left-justified on output. |
| ios::right (the default setting) | only affects the next number printed. It will be right-justified on output. |
Usage:
cout<<setiosflags(ios::fixed)<<setprecision(3)<<setw(10)<<56.11233<<setw(10)<<setprecision(5)<<56.11233<<endl;
cout<<setiosflags(ios::scientific)<<setprecision(3)<<setw(10)<<56.11233<<setw(10)<<setprecision(5)<<56.11233<<endl;
| Output: | 56.112 | 56.11233 |
| ios::fixed | causes the numbers that follow to be printed without an exponent, if possible. Once set, a number-base manipulator remains in effect until overridden by another manipulator. |
| ios::scientific | causes the numbers that follow to be printed in scientific notation e.g. normalized 1.56e-03 is the same as 0.00156. |
| setprecision(3) (3 is the default) | causes three digits to be printed to the right of the decimal point. |