title: Copying contents of one file in reverse into another file
body: <p>I have the below code, I am trying to write contents of one file in reverse into another file </p>
  
  <pre><code># include &lt;stdio.h&gt;
  # include &lt;conio.h&gt;
  # include &lt;process.h&gt;
  
  void main()
  {
      FILE *f1,*f2;
      char file1[20],file2[20];
      char ch;
      int n;
      printf("Enter the file1 name:");
      scanf("%s",file1);
      printf("Enter the file2 name:");
      scanf("%s",file2);
      f1=fopen(file1,"r");
      f2=fopen(file2,"w");
      if(f1==NULL || f2==NULL)
      {
          printf("Cannot open file");
          exit(1);
      }
      printf("Characters to read from end of file :");
      scanf("%d",&amp;n);
      fseek(f1,-n,SEEK_SET);
      while(!feof(f1))
      {
          ch=fgetc(f1);
          fputc(ch,f2);
      }
      fcloseall();
      getche();
  </code></pre>
  
  <p>But after execution , contents are not written in reverse order but it is copied as it is, I have used</p>
  
  <pre><code>fseek(f1,-n,SEEK_SET).
  </code></pre>
  
  <p>I am not sure where I went wrong.</p>