title: Reading a text file backwards and put in C
body: <blockquote>
    <p>I want to know how to read a text file backwards in C.  </p>
  </blockquote>
  
  <p>Frozen_snowman.txt is</p>
  
  <pre><code>Do you wanna build a snowman?
  Come on lets go and play
  I never see you anymore
  Come out the door
  It's like you've gone away-
  We used to be best buddies
  And now we're not
  I wish you would tell me why!-
  Do you wanna build a snowman?
  It doesn't have to be a snowman.
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int i;
      char buffer[100];
      char *a[100];
      FILE *f,*p;
      f=fopen("Frozen_snowman.txt","r");
      p=fopen("Reverse.txt","w");
      for(i=0;i&lt;10;i++)
      {
          fgets(buffer,100,f);
          a[i]=buffer;
      }
      for(i=9;i&gt;-1;i--)
      {
          fputs(a[i],p);
      }
  
      return 0;   
  }
  </code></pre>
  
  <p>Result is </p>
  
  <pre><code>It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  It doesn't have to be a snowman.
  </code></pre>
  
  <blockquote>
    <p>Why is that?</p>
  </blockquote>