C++ defines some format flags for standard input and output, which can be manipulated
with the
flags(), setf(), and
unsetf() functions. For example,
| Flag | Meaning |
| boolalpha | Boolean values can be input/output using the words "true" and
"false". |
| dec | Numeric values are displayed in decimal. |
| fixed | Display floating point values using normal notation (as opposed to
scientific). |
| hex | Numeric values are displayed in hexidecimal. |
| internal | If a numeric value is padded to fill a field, spaces are inserted between
the sign and base character. |
| left | Output is left justified. |
| oct | Numeric values are displayed in octal. |
| right | Output is right justified. |
| scientific | Display floating point values using scientific notation. |
| showbase | Display the base of all numeric values. |
| showpoint | Display a decimal and extra zeros, even when not needed. |
| showpos | Display a leading plus sign before positive numeric values. |
| skipws | Discard whitespace characters (spaces, tabs, newlines) when reading from a
stream. |
| unitbuf | Flush the buffer after each insertion. |
| uppercase | Display the "e" of scientific notation and the "x" of hexidecimal notation
as capital letters. |
| Manipulators defined in <iostream> |
| Manipulator | Description | Input | Output |
| boolalpha | Turns on the boolalpha flag | X | X |
| dec | Turns on the dec flag | X | X |
| endl | Output a newline character, flush the stream | | X |
| ends | Output a null character | | X |
| fixed | Turns on the fixed flag | | X |
| flush | Flushes the stream | | X |
| hex | Turns on the hex flag | X | X |
| internal | Turns on the internal flag | | X |
| left | Turns on the left flag | | X |
| noboolalpha | Turns off the boolalpha flag | X | X |
| noshowbase | Turns off the showbase flag | | X |
| noshowpoint | Turns off the showpoint flag | | X |
| noshowpos | Turns off the showpos flag | | X |
| noskipws | Turns off the skipws flag | X | |
| nounitbuf | Turns off the unitbuf flag | | X |
| nouppercase | Turns off the uppercase flag | | X |
| oct | Turns on the oct flag | X | X |
| right | Turns on the right flag | | X |
| scientific | Turns on the scientific flag | | X |
| showbase | Turns on the showbase flag | | X |
| showpoint | Turns on the showpoint flag | | X |
| showpos | Turns on the showpos flag | | X |
| skipws | Turns on the skipws flag | X | |
| unitbuf | Turns on the unitbuf flag | | X |
| uppercase | Turns on the uppercase flag | | X |
| ws | Skip any leading whitespace | X | |