title: Reading and writing from a file in C
body: <p>I got stuck in some basic file handling code in C. Basically I want to parse an input file to get some information, and then put it in another file (more information is in the input file). I used an online gcc compiler for that and all was great. When I<code>enter code here</code> compile the code in cmd with gcc command output file is empty.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
      char c[1000];
      FILE *fptr,*resultfp;
      if ((fptr = fopen("inputfile.txt", "r")) == NULL) {
          printf("can't be opened");
      }
      if ((resultfp = fopen("outputfile.txt", "w")) == NULL) {
          printf("can't be opened");
      }
      while(strcmp(c,"END OF FILE")){
   fscanf(fptr, "%[^\n]", c);
   fseek(fptr, 1,SEEK_CUR);
   if(strstr(c,"Example name") || strstr(c,"Example description") )
   {
      fscanf(fptr, "%[^\n]", c);
      fprintf(resultfp,"%s\n", c);
   }
  
      }
  
      fclose(fptr);
      fclose(resultfp);
      return 0;
  }
  </code></pre>
  
  <p>and this is input file:</p>
  
  <pre><code>This is an example
  Example name:
  example1
  Example description:
  description1
  Example name:
  example2
  Example description:
  description2
  I want to parse this file
  In order to get example name and example description
  END OF FILE
  </code></pre>