title: Store an integer in char array in C
body: <p>Running the code below prints <code>b =  and i = 15</code>.</p>
  
  <pre><code>int i = 15;
  char b = (char) i;
  printf("b = %c and i = %d\n", b, i);
  </code></pre>
  
  <p>How can I store this integer in the character? At the end I'm trying to have a char array of size 1024 which has <code>i</code> (15) as the first character and rest 0.</p>
  
  <p>update: I tried : </p>
  
  <pre><code>int i = 15;
  char buffer[1024];
  snprintf(buffer, 10, "%d", i);
  printf("buffer[0] = %c, buffer[1] = %c\n", buffer[0], buffer[1]);
  </code></pre>
  
  <p>And the result printed was: </p>
  
  <blockquote>
    <p>buffer[0] = 1 , buffer[1] = 5</p>
  </blockquote>