title: snprintf and sprintf explanation
body: <p>Can someone explain the output of this simple program?</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[])
  {
      char charArray[1024] = &quot;&quot;;
      char charArrayAgain[1024] = &quot;&quot;;
      int number;
  
      number = 2;
  
      sprintf(charArray, &quot;%d&quot;, number);
  
      printf(&quot;charArray : %s\n&quot;, charArray);
  
      snprintf(charArrayAgain, 1, &quot;%d&quot;, number);
      printf(&quot;charArrayAgain : %s\n&quot;, charArrayAgain);
  
      return 0;
  }
  </code></pre>
  <p>The output is:</p>
  <pre><code>./a.out 
  charArray : 2
  charArrayAgain : // Why isn't there a 2 here?
  </code></pre>