title: How to remove a file in C program?
body: <p>How do I close a file and remove it?</p>
  
  <p>I have the following code:</p>
  
  <pre><code>FILE *filePtr = fopen("fileName", "w");
  ...
  </code></pre>
  
  <p>Now I want to close filePtr and remove the file "fileName".</p>
  
  <p>Should I:</p>
  
  <pre><code>fclose(filePtr);
  remove("fileName");
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>remove("fileName");
  fclose(filePtr);
  </code></pre>
  
  <p>Does it matter which I do first?</p>
  
  <p>Thanks!!</p>