title: How do I call a function to close a file using FILE *fp
body: <p>In main I create a file pointer, pass that to a function to open it and I want to have a separate function to close the file but I am not able to close the file. What am I missing?</p>
  
  <p>I do not get an error but the way that I am checking indicates the files did not close.</p>
  
  <p>thanks for help on this.</p>
  
  <pre><code> int _tmain(int argc, _TCHAR* argv[])
  {
      FILE *inFile, *outFile;
      FileOpen(&amp;inFile, &amp;outFile);
      FileClose(&amp;inFile, &amp;outFile);
  
      getch();
      return 0;
  }
  
  void FileOpen(FILE **inFile, FILE **outFile)
  {
  //--Open InFile--------------------------------
      if ((*inFile = fopen("a.txt","r")) == NULL){
          printf("\nError Opening File. ");
          exit(0);
      }
      else {
          printf("File Opened\n");
           }
  
  //--Open OutFile--------------------------------
      if ((*outFile = fopen("b.txt","w")) == NULL){
          printf("\nError Opening File. ");
          exit(0);
      }
      else {
          printf("File Opened\n");
           }
  }
  
  
  void FileClose(FILE **inFile, FILE **outFile)
  {
  //--Close InFile----------
      if (fclose(*inFile)){
          printf("File Closed\n");
      }
      else {
           printf("\nError Closing InFile File. ");
      }
  
  //--Close outFile---------
      if (fclose(*outFile)){
          printf("File Closed\n");
  
      }
      else {
           printf("\nError Closing OutFile File. ");
      }
   }
  </code></pre>