title: How to iterate backwards in an array in C?
body: <p>I am trying to input a string of characters, and then output them backwards like </p>
  
  <p>Input: Hello
  Output: olleH</p>
  
  <p>I have a working example, however I am getting every single letter except the last.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define MAX_SIZE 100
  
  int main(void) {
  int my_stg2[MAX_SIZE];
  int i = 0;
  int j;
  char my_stg[MAX_SIZE];
  
  int input ;
  
  input = getchar();
  
  while (input != '\n'){//The new line is the stopping point.
  
  
      my_stg2[i] = input;
      ++i;
   input = getchar();
  
  
  }
      for (j=0;i&gt;=0;i--){
  
  
  
      my_stg[j]  = my_stg2[i];
      j++;
  }
  
  printf("%s\n" , my_stg);
  
  }
  </code></pre>
  
  <p>I tried the above code, however I am getting weird output with large strings. Can someone fix the loop for me? <a href="http://imgur.com/PK97b.png" rel="nofollow">http://imgur.com/PK97b.png</a></p>