public member function
<ios>
fmtflags flags ( ) const;
fmtflags flags ( fmtflags fmtfl );
Get/set format flags
The first syntax returns the current set of format flags set for the stream.
The second syntax sets a new set of format flags for the stream, returning its former value.
The format flags of a stream affect the way data is interpreted in certain input functions and how it is written by certain output functions. See
ios_base::fmtflags for the possible values of this function's argument.
The second syntax of this function sets the value for
all the format flags of the stream, overwritting the existing values and clearing any flag not explicitly set in the argument. To modify just a single format flag, the member functions
setf and
unsetf are generally preferred.
Parameters
- fmtfl
- Format flags to be used by the stream. It is a value of type ios_base::fmtflags.
Return Value
The format flags of the stream before the call.
Example
1 2 3 4 5 6 7 8 9 10
|
// modify flags
#include <iostream>
using namespace std;
int main () {
cout.flags ( ios::right | ios::hex | ios::showbase );
cout.width (10);
cout << 100;
return 0;
}
|
This simple example sets some format flags for
cout that affect the latter insertion operation by printing the value in hexadecimal base format (
0x64) padded right as in a field ten spaces long:
See also
- ios_base::setf
- Set specific format flags (public member function)
- ios_base::unsetf
- Clear specific format flags (public member function)
- ios_base::fmtflags
- Type for stream format flags (public member type)
- setiosflags
- Set format flags (function)