 <p>No, you shouldn't use the above instead of <code>atoi</code>.</p> <p>You should actually check the error information that <code>strtol</code> makes available:</p> <pre><code>i = atoi(s); </code></pre> <p>should be replaced by</p> <pre><code>char* stopped; i = (int)strtol(s, &amp;stopped, 10); if (*stopped) { /* handle error */ } </code></pre>