cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : manipulators
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
manipulators
· boolalpha
· dec
· endl
· ends
· fixed
· flush
· hex
· internal
· left
· noboolalpha
· noshowbase
· noshowpoint
· noshowpos
· noskipws
· nounitbuf
· nouppercase
· oct
· resetiosflags
· right
· scientific
· setbase
· setfill
· setiosflags
· setprecision
· setw
· showbase
· showpoint
· showpos
· skipws
· unitbuf
· uppercase
· ws

-

manipulators

Stream manipulators

Manipulators are functions specifically designed to be used in conjunction with the insertion (<<) and extraction (>>) operators on stream objects, for example:

cout << boolalpha;

They are still regular functions and can also be called as any other function using a stream object as argument, for example:

boolalpha (cout);

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 (manipulator function)
showbase Show numerical base prefixes (manipulator function)
showpoint Show decimal point (manipulator function)
showpos Show positive signs (manipulator function)
skipws Skip whitespaces (manipulator function)
unitbuf Flush buffer after insertions (manipulator function)
uppercase Generate upper-case letters (manipulator function)
Independent flags (switch off):
noboolalpha No alphanumerical bool values (manipulator function)
noshowbase Do not show numerical base prefixes (manipulator function)
noshowpoint Do not show decimal point (manipulator function)
noshowpos Do not show positive signs (manipulator function)
noskipws Do not skip whitespaces (manipulator function)
nounitbuf Do not force flushes after insertions (manipulator function)
nouppercase Do not generate upper case letters (manipulator function)
Numerical base format flags ("basefield" flags):
dec Use decimal base (manipulator function)
hex Use hexadecimal base (manipulator function)
oct Use octal base (manipulator function)
Floating-point format flags ("floatfield" flags):
fixed Use fixed-point notation (manipulator function)
scientific Use scientific notation (manipulator function)
Adustment format flags ("adjustfield" flags):
internal Adjust field by inserting characters at an internal position (manipulator function)
left Adjust output to the left (manipulator function)
right Adjust output to the right (manipulator function)

Input manipulators

ws Extract whitespaces (manipulator function)

Output manipulators

endl Insert newline and flush (manipulator function)
ends Insert null character (manipulator function)
flush Flush stream buffer (manipulator 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 (manipulator function)
resetiosflags Reset format flags (manipulator function)
setbase Set basefield flag (manipulator function)
setfill Set fill character (manipulator function)
setprecision Set decimal precision (manipulator function)
setw Set field width (manipulator function)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us