title: How to use an array to take command line arguments?
body: <p>So I'm trying to use cmd to take arguments while starting the program, but I keep running into issues from converting the variables from char to int, so they can be used with the rest of the program. Thanks for the help ahead of time. </p>
  
  <pre><code>int main(int argc, char* argv[]) {
      int n = 0, a = 0, b = 0, func = 0, choice = 0;
      double w;
      if(argc &lt; 10)
      {
          cout &lt;&lt; "The Program requires -f &lt;Function&gt; -a &lt;Starting Point&gt; -b &lt;Ending Point&gt; -m &lt;Method&gt; -n &lt;Number of slices&gt;" &lt;&lt; endl;
          exit(0);
      }
      else
      {
          int func, a, b, choice, n;
          int i;
          for(int i = 1; i &lt; argc - 1; i+=2)
          {
                  if(argv[i] == "-f"){
                      func = *argv[i + 1];}
                  else if(argv[i] == "-a"){
                      a = *argv[i + 1];}
                  else if(argv[i] == "-b"){
                      b = *argv[i + 1];}
                  else if(argv[i] == "-m"){
                      choice = *argv[i + 1];}
                  else if(argv[i] == "-n"){
                      n = *argv[i + 1];}
                  else {
                      cout &lt;&lt; "Input is Invalid" &lt;&lt; endl;
                      exit(0);}
                  cout &lt;&lt; argv[i] &lt;&lt; endl;
          }
          w = (b-a)/double(n);
          next(n, a, b, w, func, choice);
      }
      return 0;
  }
  </code></pre>
  
  <p>edit: So I have restructured my code to look like that above and it does compile, but I'm getting only the else statement. Such as when is start the program using a line like: ./a3 -f 5 -a 1 -b 10 -m 3 -n 100. I'm not sure why the program reverts to the else statement "input is Invalid" instead of the other if, if else statements.  </p>