title: Copying the lines from a file to another backwards in c
body: <p>I'm trying to copy the file itself with the same permissions, same size, same all to another one (new), I did it but copying the content normal, but now trying to copy it backwards (last line is the first on the new file), how I planned this is, first get the number of lines of a file as follows :</p>
  
  <pre><code>while (!feof(fp)) {
      ch = fgetc(fp);
      if (ch == '\n') {
          lines++;
      }
  }
  </code></pre>
  
  <p>Then create an array to put each line from the file, once I have that array full with a <code>for</code> </p>
  
  <pre><code>for (unsigned i = n; i-- &gt; 0;) {
      //n is the number of lines
  }
  </code></pre>
  
  <p>Then on this <code>for</code> I write to a doc then it will be written backwards, is there a better option to do this?</p>
  
  <p>Could you give me an example if so?</p>