title: How do I get a negative value by using atoi()?
body: <p>I wrote this code to get a number in reverse form. But if I use any negative input it shows positive reversed number. Can the atoi function in C handle negatives?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void) {
    char ar[40];
    char ar2[40];
    int fnum;
    scanf(&quot;%s&quot;, ar);
  
    for (int i = strlen(ar) - 1, j = 0; i &gt;= 0; i--) {
      ar2[j] = ar[i];
      j++;
    }
  
    fnum = atoi(ar2);
    printf(&quot;%d&quot;, fnum);
    return 0;
  }
  </code></pre>