fmtflags flags ( ) const;
fmtflags flags ( fmtflags fmtfl );

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.


Format flags to be used by the stream. It is a value of type fmtflags.

Return Value.
  The format flags of the stream before the call.


// 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

© The C++ Resources Network, 2001