title: C Programming take "n" command line arguments and find the min of all arguments
body: <p>I have a project that I am working on for my class and my teacher did not explain any of this very well. I really need help with it because I really have no idea how to go about it.</p>
  
  <p>The assignment states that the program needs "to read n integers from the keyboard, where n should be given as a command line argument. "</p>
  
  <p>It should look like this </p>
  
  <pre><code>./a.out 3
  20 30 10
  The smallest one is 10.
  </code></pre>
  
  <p>Where the 3 is n and 20, 30, and 10 are all entered by the user and then the program will find the minimum value of the entered ones.</p>
  
  <p>Also my program needs to "check whether the number of the command line arguments and the value of n is correct or not. If not, you should provide an error information as the following example"</p>
  
  <pre><code>./a.out 10 20
  Please input the number of integers as ./a.out number
  
  ./a.out 0    
  Please input the number of integers as ./a.out number
  </code></pre>
  
  <p>He also gave us this "Hint: you may use the <code>int atoi(char *)</code> function to convert a string value to an integer
  value."</p>
  
  <p>Below is what I have gotten so far, but I have no idea how to related the command line arguments to n or vice versa. I'm very confused and could really use some help.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[])
  {
      int num1, num2, min, max;
  
      if (argc == 2) {
          scanf("%d %d", &amp;num1, &amp;num2);
          if(num1&gt;num2)
              max=num1, min=num2;
          if(num2&gt;num1)
              max=num2, min=num1;
  
          printf("The smaller one is %d \n", min);
      }
  }
  </code></pre>