showflag.cpp
上传用户:dq031136
上传日期:2022-08-08
资源大小:802k
文件大小:1k
源码类别:

VC书籍

开发平台:

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.  }