title: sprintf to reverse an int and store as char
body: <p>I"m trying to store int array as a str and display it but in the reverse order.
  Its only while printing the str that i get junk.</p>
  
  <p>What is wrong in my code?</p>
  
  <pre><code>int main() {
      int a[] = { 1, 2, 3 }; // Output should be 321 (char)
      int size = sizeof(a) / sizeof(int);
      char str[size + 1];
      int i;
      for (size = size - 1; size &gt;= 0; size--) {
          sprintf(&amp;str[size], "%d", a[size]);
          //printf("%c\n", str[size]);
      }
      printf("%s\n", str); // I get garbage.
  }
  </code></pre>