title: fopen is not opening a file stream... how do I resolve this?
body: <p>I am trying to write a file and append data to it.</p>
  
  <p>Here is a snippet of my code.  thresh is an unsigned short.</p>
  
  <pre><code>    FILE *fp_th;
      fp_th = fopen("threshold.txt", "a");
      printf("opening file failed: %s\n", strerror(errno));
  fprintf(fp_th,"%d ", thresh);
      fclose(fp_th);
  </code></pre>
  
  <p>Before it has worked fine, but I've changed some of my code and all of a sudden it doesn't print out anymore.</p>
  
  <p>I've confirmed that fopen isn't opening a file stream with</p>
  
  <pre><code>printf(" check fp_th = %p \n", fp_th);
  </code></pre>
  
  <p>It prints out <code>check fp_th = 00000000</code>.  </p>
  
  <p>EDIT: Added <code>printf("opening file failed: %s\n", strerror(errno));</code> after fopen.  Output says no error.  Does it lie?  Odd..</p>
  
  <p>The odd thing is that I am writing and appending a similar file, and yet that file works fine.  How do you resolve a fopen that returns a NULL?  Why does it happen?  Thanks!</p>