You are on page 1of 2

Input/output manipulators

Manipulators are helper functions that make it pos s ible to control input/output s treams us ing
operator<< or operator>>.
The manipulators that are invoked without arguments (e.g. std::cout << std::boolalpha; or
std::cin >> std::hex;) are implemented as functions that take a reference to a s tream as their only
argument. The s pecial overloads of basic_ostream::operator<<and basic_istream::operator>>
accept pointers to thes e functions .
The manipulators that are invoked with arguments (e.g. std::cout << std::setw(10);) are
implemented as functions returning objects of uns pecied type. Thes e manipulators dene their own
operator<<or operator>>which perform the reques ted manipulation.
Dened in header <ios>

boolalpha
noboolalpha

s witches between textual and numeric repres entation of booleans

showbase
noshowbase

controls whether prex is us ed to indicate numeric bas e

showpoint
noshowpoint

(func tion)
(func tion)

controls whether decimal point is always included in oating-point


repres entation
(func tion)

showpos
noshowpos

controls whether the +s ign us ed with non-negative numbers

skipws
noskipws

controls whether leading whites pace is s kipped on input

uppercase
nouppercase

controls whether uppercas e characters are us ed with s ome output formats

unitbuf
nounitbuf

controls whether output is us hed after each operation

internal
left
right
dec
hex
oct

(func tion)
(func tion)
(func tion)
(func tion)

s ets the placement of ll characters


(func tion)

changes the bas e us ed for integer I/O


(func tion)

fixed

scientific
changes formatting us ed for oating-point I/O
hexfloat
(C++11) (func tion)
defaultfloat(C++11)
Dened in header <istream>

ws

cons umes whites pace

(func tion template)


Dened in header <ostream>

ends
flush
endl

outputs '\0'
(func tion template)

us hes the output s tream


(func tion template)

outputs '\n' and us hes the output s tream

(func tion template)


Dened in header <iomanip>

resetiosflags
setiosflags
setbase
setfill
setprecision
setw
get_money(C++11)
put_money(C++11)
get_time(C++11)

clears the s pecied ios _bas e ags


(func tion)

s ets the s pecied ios _bas e ags


(func tion)

changes the bas e us ed for integer I/O


(func tion)

changes the ll character


(func tion template)

changes oating-point precis ion


(func tion)

changes the width of the next input/output eld


(func tion)

pars es a monetary value


(func tion template)

formats and outputs a monetary value


(func tion template)

pars es a date/time value of s pecied format


(func tion template)

put_time(C++11)
quoted(C++14)

formats and outputs a date/time value according to the s pecied format


(func tion template)

ins erts and extracts quoted s trings with embedded s paces


(func tion template)

Retrieved from "http://en.c ppreferenc e.c om/mwiki/index.php?title=c pp/io/manip& oldid=57896"