title: failing to dump the input file reversed
body: <p>I want to reverse the contents of the input file and display the reversed contents, but I am not getting it; i think I have made a logic error.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;stdio.h&gt;
  
  int main() {
      char* c = malloc(10);
      char* c1 = malloc(10);
      char ch, arg1[100], arg2[100];
      int i, count = 0;
      FILE *fp, *fq;
      printf("Name of the file:");
      scanf("%s", arg1);
      fp = fopen(arg1, "w+");
      if (!fp) {
          perror("Failed to open file");
          return errno;
      }
  
      printf("\t\t\t%s\n\n", arg1);
      printf("\t\tInput the text into the file\n");
      printf("\t\tPress Ctrl+d to the stop\n");
      while ((*c=getchar()) != EOF) {
          fwrite(c, 1, sizeof(c), fp);
          count++;
      }
  
      printf("\n\n");
      fclose(fp);
      fp = fopen(arg1, "w+");
      printf("Name of the output file:");
      scanf("%s", arg2);
      printf("Reversing the contents of the file.......\n");
      fq = fopen(arg2, "w+");
      printf("\t\t%s\n\n", arg2);
      for (i = 1; i &lt;= count; i++) {
          fseek(fp, -(i + 1), SEEK_END)
          fwrite(c1, 1, sizeof(c1), fq);
      }
      printf("Done....Opening the file\n");
      rewind(fq);
      for (i = 0; i &lt;= count; i++) {
          ch = getc(fp);
          putc(ch, stdout);
      }
      fclose(fp);
      fclose(fq);
      return 0;
  }
  </code></pre>