S
H
A
R
E
Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Sunday, May 22, 2011

C++ Output String Manipulator


Manipulator                              Action
dec                               Set decimal conversion base format flag.
hex                               Set hexadecimal conversion base format flag.
oct                               Set octal conversion base format flag.
ws                                Extract whitespace characters.
endl                              Insert newline and flush stream.
ends                             Insert terminal null in string.
flush                             Flush an ostream.
setbase(int n)                Set conversion base format to base n (0, 8, 10, or 16). 0 means the default: decimal on output,                          ANSI C rules for literal integers on input.

resetiosflags(long f)       Clear the format bits specified by f.
setiosflags(long f)          Set the format bits specified by f.
setfill(int c)                    Set the fill character to c.
setprecision(int n)          Set the floating-point precision to n.
setw(int n)                     Set field width to n.


Sample Use:
int i = 36;
cout << dec << i << " " << hex << i << " " << oct << i << endl;
cout << dec;  // Must reset to use decimal base.
// displays 36 24 44


Read More!