Mega Code Archive

 
Categories / C++ Tutorial / Development
 

Check cout flags

#include<iostream.h> void showflags(); main() {   showflags();   cout.setf(ios::oct|ios::showbase|ios::fixed);   showflags();   return 0; } void showflags() {   long f;   char flgs[15][12]={     "skipws",        "left",        "right",        "internal",        "dec",        "oct",        "hex",        "showbase",        "showpoint",        "uppercase",        "showpos",        "scientific",        "fixed",        "unitbuf",        "stdio",   };   f=cout.flags();   for(int i=1,j=0;i<0x4000;i=i<<1,j++)     if(i&f)          cout<<flgs[j]<<"is on\n";        else          cout<<flgs[j]<<"is off\n";   cout<<"\n"; } skipwsis off leftis on rightis off internalis off decis off octis off hexis off showbaseis off showpointis off uppercaseis off showposis off scientificis off fixedis on unitbufis off skipwsis off leftis on rightis on internalis off decis off octis off hexis on showbaseis off showpointis off uppercaseis on showposis off scientificis off fixedis on unitbufis off