ios_base::flags
fmtflags flags ( ) const; fmtflags flags ( fmtflags fmtfl ); | ios_base |
cplusplus.com |
Get/set format flags.
The first syntax returns the current set of format flags for the stream.
The second syntax sets fmtfl as the format flags for the stream.
The stored format flags affects the way data is interpreted in certain input functions
and how it is written by certain output functions.
The values of the different format flags are explained in the
fmtflags type reference.
The second syntax of this function sets the value for all the format flags of the stream. If you want to modify a single flag refer to setf and unsetf.
Parameters.
Return Value.
The format flags of the stream before the call.
Example.
// modify flags
#include <iostream>
using namespace std;
int main () {
cout.flags ( ios_base::right | ios_base::hex | ios_base::showbase );
cout.width (10);
cout << 100;
return 0;
}
This simple example sets some format flags for cout affecting the
later insertion operation by printing the value in hexadecimal base format padded right
as in a field ten spaces long.
See also.
setf,
unsetf
fmtflags type,
ios_base class