title: snprintf, for integer to string conversion in C
body: <p>I have a little piece of code to convert an integer to a string in c.
  The code has to work on both 32-bits and 64 bits platform.</p>
  
  <p>I am parsing arguments in a loop, so I need malloc to create the buffer</p>
  
  <pre><code>int tmp_integer = /*read as integer*/
  char* tmp_string = malloc(20* sizeof(char)); /*enough room for the biggest integer*/
  snprintf(tmp_string, 20,"%d",tmp_integer); /*can I avoid using 20 here*/
  a[i - 1] = tmp_string; /*save the parsed argument for final usage*/
  </code></pre>
  
  <p>My question is :
  Is there any way to make it nice using snprintf, or should I fall back to sprintf.</p>
  
  <p>I figured that using snprintf was not the right thing to do, because originally I wanted to be protected from buffer overruns, but since the size of integer is known I think it is useless. Still I would like to know what is the best practice here.</p>