title: Simple Calculator using command line argument C++
body: <p>I'm new to C++. I'm writing a simple calculator using command line. The command line should have this format:
  <strong>programname  firstNumber  operator  secondNumber</strong>
  Here what I got so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      if (argc != 3)
      {
          cerr &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; endl;
          exit(0);
      }
      else
      {
          int firstNumber = atoi(argv[1]);
          char theOperator = atoi(argv[2]);
          int secondNumber = atoi(argv[3]);
          switch (theOperator)
          {
          case'+':
              {
                  cout &lt;&lt; "The answer is " &lt;&lt; firstNumber + secondNumber &lt;&lt; endl;
                  break;
              }
          case '-':
              {
                  cout &lt;&lt; "The answer is " &lt;&lt; firstNumber - secondNumber &lt;&lt; endl;
                  break;
              }
          case '*':
              {
                  cout &lt;&lt; "The answer is " &lt;&lt; firstNumber * secondNumber &lt;&lt; endl;
                  break;
              }
          case '/':
              {
                  if (secondNumber == 0)
                  {
                      cout &lt;&lt; "Can not devide by a ZERO" &lt;&lt; endl;
                      break;
                  }
                  else
                  {
                      cout &lt;&lt; "The answer is " &lt;&lt; firstNumber / secondNumber &lt;&lt; endl;
                      break;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>The program does not run. When I run it, it displays an appropriate usage message and end the program. Can anyone please help me?</p>