title: Using if/then statements to parse argv[ ] options in C++
body: <p>How would you use an if/then statement using argv[], upon the option/parameter entered?</p>
  
  <p>For example, <em>a.out -d 1 sample.txt</em> versus <em>a.out -e 1 sample.txt</em>. </p>
  
  <pre><code>int main (int argc, char *argv[])
  {
    ifstream infile(argv[3]);
  
    int c;
    int number = 0;
    int count = 0;
  
    while ( infile.good() ) {
  
              if (argv[1] == "-d")
              {
  
                   c = infile.get();
  
                   number = atoi(argv[2]);  
  
                    if (number == count)
                   {
                   cout.put(c);
                   count = 0;
                   }
  
                        else
                          count++;
  
              }       
  
  
             if (argv[1] == "-e")
             { 
                cout &lt;&lt; "entered -e" &lt;&lt; endl;   //testing code
             }
  
  
    }//end while
  
  }//end main
  </code></pre>