Store cout flags, set to new ones and restore : cout flag status « Console « C++






Store cout flags, set to new ones and restore

Store cout flags, set to new ones and restore

#include <iostream>
using namespace std;

int main()
{
  ios::fmtflags f;

  f = cout.flags(); // store flags

  cout.unsetf(ios::dec);
  cout.setf(ios::showbase | ios::hex);
  cout << 100 << '\n';

  cout.flags(f); // reset flags

  return 0;
}


           
       








Related examples in the same category

1.Using Manipulators to Format I/OUsing Manipulators to Format I/O
2.cout flags: showpoint, showposcout flags: showpoint, showpos
3.Displays the status of the format flags.Displays the status of the format flags.