title: Arguments passed to the command line not printed and the program loops indefinitely
body: <p>I'm trying to implement a simple command line program that takes three arguments and prints them on the linux terminal </p>
  
  <p>For example:</p>
  
  <pre><code>&gt;c++ exec.cpp
  
  &gt;./a 32 + 32
  </code></pre>
  
  <p>Should print out contents like this</p>
  
  <p>32</p>
  
  <p>+</p>
  
  <p>32</p>
  
  <p>But the program is looping indefinitely</p>
  
  <p>I've implemented a check for argc
  Like this</p>
  
  <pre><code>if(argc!=3) {
  cout &lt;&lt; "Exit" &lt;&lt; endl;
  return -9999;
  }
  </code></pre>
  
  <p>In case the argument count is 3 </p>
  
  <p>These lines of code should be executed</p>
  
  <pre><code>else {
  for(int i=0;i&lt;argc;i++){
  cout &lt;&lt; argv[i] &lt;&lt; endl;
  }
  }
  </code></pre>
  
  <p>But as I explained before the program loops indefinitely</p>
  
  <p>EDIT:
  Since I was asked to post the entire code here it is</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main(int argc,char* argv[]) {
   if(argc!=3) {
      cout &lt;&lt; "Exit" &lt;&lt; endl;
      return -9999;
      }
  else {
      for(int i=0;i&lt;argc;i++){
      cout &lt;&lt; argv[i] &lt;&lt; endl;
      }
      }
  }
  </code></pre>