Input/Output in C++

Manipulators

Manipulator Description
boolalpha bool input and output as true or false.
noboolalpha bool IO or 1 or 0.
endl Write newline character(s) and flush output stream.
flush Flush output stream to disk.
dec Input or output in decimal format.
hex Input or output in hex format.
oct Input or output in octal format.
fixed Fixed notation for floating point: d.ddd.
left Left justify output.
right Right justify output.
scientific Display floating point output as d.dddedd.
setw(n) Set output field width to n.
setprecision(n) Set floating point precision to n.
showpoint Show decimal point and trailing zeros.
noshowpoint Supress trailing zeros and decimal point if possible.
showpos Show plus sign for positive numbers.
noshowpos Do not show plus sign for positive numbers.
skipws Skip white space for input.
noskipws Do not skip white space for input.
ws Remove white space.
 

Flags in the ios Class

Format Flags

Flag Name Description Bit Number
boolalpha bool input and output as true or false. 2
fixed Fixed notation for floating point: d.ddd. 3
scientific Display floating point output as d.dddedd. 4
hex Input or output in hex format. 5
oct Input or output in octal format. 6
dec Input or output in decimal format. 7
internal Left justify output. 8
left Left justify output. 9
right Left justify output. 10
showpos Show decimal point and trailing zeros. 11
showpoint Show decimal point and trailing zeros. 12
showbase Show leading 0 for octal or 0x for hex. 13
uppercase Use uppercase for hex output. 14
unitbuf Flush any stream after write. 15
skipws Skip whitespace in input. 16
adjustfield Value is left, right, or internal.  
basefield Value is dec, oct, or hex.  
floatfield Value is scientific or fixed.  
 

Input/Output Status Flags

Name If Set Bit Number
badbit Bad input or output source 3
failbit Failure to read intput or produce expected output. 4
eofbit End of file for input or output. 2
goodbit Successful input or output.  
 

Input/Output Mode Flags

Name If Set Bit Number
binary Open as binary. 3
trunc Truncate stream if already exists. 4
app Open file for append. 5
ate Open for read and move to end of file. 6
out Open for output starting at beginning of file. 7
in Open for input starting at beginning of file. 8
 

Seek Offset Flags

Name If Set Bit Number
end Seek from end of file.6
cur Seek from current position of file. 7
beg Seek from beginning of file. 8