fork(2) download
  1. #include <iostream>
  2. #include <ios>
  3. #include <bitset>
  4. using std::cout;
  5. using std::endl;
  6. using std::bitset;
  7. using std::ios;
  8. typedef std::ios_base::fmtflags flags_t;
  9. void printFlags(const char* msg) {
  10. flags_t flags = cout.flags();
  11. bitset<sizeof(flags) * 8> bset(flags);
  12. cout << msg << " : " << bset << endl;
  13. }
  14. int main() {
  15. printFlags("before ");
  16. cout.setf(ios::hex, ios::basefield);
  17. printFlags("after setf ");
  18. cout.unsetf(ios::hex);
  19. printFlags("after unsetf");
  20. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
before       : 00000000000000000001000000000010
after setf   : 00000000000000000001000000001000
after unsetf : 00000000000000000001000000000000