<ios> <iostream>
std::manipulators
Stream manipulators
Manipulators are functions specifically designed to be used in conjunction with the insertion (
<<) and extraction (
>>) operators on stream objects, for example:
They are still regular functions and can also be called as any other function using a stream object as argument, for example:
Manipulators are used to change formatting parameters on streams and to insert or extract certain special characters.
Basic format flags
These manipulators are usable on both input and output streams, although many only have an effect when applied to either output or input streams.
Independent flags (switch on):
- boolalpha
- Alphanumerical bool values (function
)
- showbase
- Show numerical base prefixes (function
)
- showpoint
- Show decimal point (function
)
- showpos
- Show positive signs (function
)
- skipws
- Skip whitespaces (function
)
- unitbuf
- Flush buffer after insertions (function
)
- uppercase
- Generate upper-case letters (function
)
Independent flags (switch off):
- noboolalpha
- No alphanumerical bool values (function
)
- noshowbase
- Do not show numerical base prefixes (function
)
- noshowpoint
- Do not show decimal point (function
)
- noshowpos
- Do not show positive signs (function
)
- noskipws
- Do not skip whitespaces (function
)
- nounitbuf
- Do not force flushes after insertions (function
)
- nouppercase
- Do not generate upper case letters (function
)
Numerical base format flags ("basefield" flags):
- dec
- Use decimal base (function
)
- hex
- Use hexadecimal base (function
)
- oct
- Use octal base (function
)
Floating-point format flags ("floatfield" flags):
- fixed
- Use fixed floating-point notation (function
)
- scientific
- Use scientific floating-point notation (function
)
Adustment format flags ("adjustfield" flags):
- internal
- Adjust field by inserting characters at an internal position (function
)
- left
- Adjust output to the left (function
)
- right
- Adjust output to the right (function
)
Input manipulators
- ws
- Extract whitespaces (function
)
Output manipulators
- endl
- Insert newline and flush (function
)
- ends
- Insert null character (function
)
- flush
- Flush stream buffer (function
)
Parameterized manipulators
These functions take parameters when used as manipulators. They require the explicit inclusion of the header file
<iomanip>.
- setiosflags
- Set format flags (function
)
- resetiosflags
- Reset format flags (function
)
- setbase
- Set basefield flag (function
)
- setfill
- Set fill character (function
)
- setprecision
- Set decimal precision (function
)
- setw
- Set field width (function
)