title: How to check if command line parameters are integers
body: <p>First of all, I am talking about old-fashioned ANSI-C (I mean the ANSI standard and no C99 or newer) compiled with gcc. I am only allowed to use the libraries that can be seen below in the code.</p>
  
  <p>My problem is I have a program that is called in the following way on the Terminal:</p>
  
  <pre><code>program &lt; integer_1 integer_2
  </code></pre>
  
  <p>While I have been able to figure out how to check for the number of arguments, I'm stuck on checking if those are integers.
  If the program is called like this:</p>
  
  <pre><code>program &lt; 1 -13
  </code></pre>
  
  <p>it should run without complaining but if it is run like this:</p>
  
  <pre><code>program &lt; s 7
  </code></pre>
  
  <p>it should throw out an error.</p>
  
  <p>Whatever I have tried so far has been utter rubbish. The best thing I have managed so far has been an error message if the second number has been a character. None of my tries has been able to deal with more than one digit but I have figured out why that is.</p>
  
  <p>The problem is that I haven't used command line / terminal arguments with any programming language i now (C++, Java). I would really appreciate it if someone could show me how check for correct input as frankly I am out of ideas.</p>
  
  <p>Am I correct that if I want to deal with numbers bigger than 9, I have to iterate through argv starting from index 2 until I find a space?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;limits.h&gt;
  
  int main(int arc, char *argv[])
  {
    if(arc != 3)
    {
      printf("Error: You have entered %d arguments, but two were expected!", arc - 1);
      return -1;
    }
  
    return 0;
  }
  </code></pre>