title: Convert ASCII string to int/float/long
body: <p>I have this code to convert an ASCII string to and int, float, or double. However, it prints "42" for all of them. Where did I go wrong? The syntax looks correct, no warnings.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  int main(void)
  {
       char *buf1 = "42";
       char buf2[] = "69.00";
       int i;
       double d;
       long l;
       i = atoi(buf1);
       l = atol(buf1);
       d = atof(buf2);
       printf("%d\t%d\t%d\n", i, l, d);
       return 0;
  }
  </code></pre>