showflag.cpp
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Development Platform:

C++ Builder

  1. #include <iostream.h>
  2. void showflags(void);
  3. void main(void)
  4.  {
  5.    showflags();
  6.    cout.setf(ios::right | ios::showpoint | ios::fixed);
  7.    showflags();
  8.  }
  9. void showflags(void)
  10.  {
  11.    long flag_set, i;
  12.    int j;
  13.    char flags[15][12] = {
  14.       "skipws", "left", "right", "internal", "dec",
  15.       "oct", "hex", "showbase", "showpoint", "uppercase",
  16.       "showpos", "scientific", "fixed", "unitbuf",
  17.    };
  18.    flag_set = cout.flags();
  19.    for (i=1, j=0; i<0x2000; i = i<<1, j++)
  20.       if (i & flag_set)
  21.          cout << flags[j] << " is on." << endl;
  22.       else
  23.          cout << flags[j] << " is off." << endl;
  24.    cout << endl;
  25.  }