Javatpoint Logo
Javatpoint Logo

C++ Std Manipulators

Manipulators are helper function which can be used for formatting input and output data. Manipulators specifically designed to be used in conjunction with the insertion (<<) and extraction (>>) operators on stream objects, for example:

  • The iostream.h and iomanip.h header file has several pre-defined manipulators.

Basic format flags

Independent flags (switch on)

boolalpha Alphanumerical bool values.
showbase Show numerical base prefixes.
showpoint Show decimal point.
showpos Show positive signs.
skipws Skip whitespaces.
unitbuf Flush buffer after insertions.
uppercase Generate upper case letters.

Independent flags (switch off)

noboolalpha Do alphanumerical bool values.
noshowbase Do not show numerical base prefixes.
noshowpoint Do not show decimal point.
noshowpos Do not show positive signs.
noskipws Do not skip whitespaces.
nounitbuf Do not force flushes after insertions.
nouppercase Do not generate upper case letters.

Numerical base format flags ("basefield" flags)

dec Use decimal base.
hex Use hexadecimal base
oct Use octal base.

Floating point format flags ("floatfield" flags)

fixed Use fixed floating point notation.
scientific Use scientific floating point notation.

Adjustment format flags ("adjustfileld "flags)

internal Sets field by inserting characters at an internal position.
left Adjust output to the left.
right Adjust output to the right.

Input manipulators

ws Extract whitespaces.

Output manipulators

endl Insert newline and flush.
ends Insert null characters.
flush Flush stream buffer.

Parameterized manipulators

These functions take parameters when used as manipulators. They require inclusion of <iomanip> header file.

setiosflags Set format flags.
resetiosflags Reset format flags.
setbase Set basefield flag.
setfill Set fill character.
setprecision Set decimal precision.
setw Set field width.

Next TopicC++ Manipulator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA