title: Return value of atoi (argv[1]) is always 0
body: <p>I'm running into a problem about return value of <code>atoi()</code>.</p>
  
  <p>I want to convert the <code>char</code> in command line argument <code>argv[1]</code> into <code>int</code> type and print it out.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char *argv[])
  {
      int i;
      //print the char in *argv[]
      for(i = 0; i &lt; argc; i++)
      {
              fprintf(stdout, "Arg %d: %s\n", i, argv[i]);
      }
  
      if (argc &gt; 1)
      {
          i = atoi(argv[1]);      //convert char to int
          fprintf(stdout, "Int version of 1st arg: %d\n", i);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I compile it by gcc and run it like <code>./a.out a b c</code></p>
  
  <p>Other result is correct, but the <code>atoi()</code> result always displays as </p>
  
  <pre><code>Int version of 1st arg: 0
  </code></pre>
  
  <p>Could you give me some suggestion on this topic?</p>