title: Properly close a file with both a file descriptor and file pointer
body: <p>For formatted writes with <code>fprintf()</code>, I'm using a <code>FILE</code> pointer obtained from a file descriptor created by <code>mkstemp()</code> (<a href="https://stackoverflow.com/questions/1941464/how-to-get-a-file-pointer-from-a-file-descriptor">see this link</a>):</p>
  
  <pre><code>fd = mkstemp(tmpName);
  
  FILE *fp = fdopen(fd, "w");
  fprintf(fp, "#EXTM3U\n");
  </code></pre>
  
  <p>What is the proper procedure to close the file?</p>
  
  <pre><code>fclose(fp) // only?
  
  fclose(fp); // both?
  close(fd);
  
  close(fd); // only?
  </code></pre>