/*
 * short program to demonstrate command line processing and use
 * of STL bitset.
 */
#include <bitset>
#include <iostream>
using namespace std;

int main(int argc, char* argv[]) 
{
   std::bitset<40> b;
   std::bitset<12> c(231);
   
   // note that bit 0 will appear right most and bit 39 will be 
   // left-most in the output. bit 0 is the least significant bit.
   b.set(0); b.set(1); b.set(2); b.set(5); b.set(10);   
   std::cout << "b " << b << std::endl;
   
   // this will print bit pattern for the integer 231
   std::cout << "c " << c << std::endl;
   
   // now command line processing. The parameter 'argc' contains the
   // count of the arguments on the command line. It includes the
   // name of the command. Thus, if this program was started with in a
   // DOS window
   // 
   //   .\bitset  333 234 foo.txt msg.dat
   //
   // Then argc and argv will have:
   //    argc = 5
   //    argv[0] = ".\bitset"  (the command itself)
   //    argv[1] = "333"      (first arg)
   //    argv[2] = "234"      (second arg)
   //    argv[3] = "foo.txt"
   //    argv[4] = "msg.dat"
   //
   //  You can also specify command line arguments in DevCpp in menu item
   //  Execute->Parameters->Parameters to pass to your program.
   
   for(int i = 1; i <= argc; i++ )
     std::cout << "argv[" << i-1 << "] = " << argv[i-1] << std::endl;
     
   // If the second arg was a file name, it could be opened with
   //  fopen(argv[1], "r")  or
   //  ifstream file( argv[1] );
   
   system("pause");
}

