title: `fopen` does not return NULL but did not open the file either
body: <p>I have been running the same code for quite some time and this morning <code>fopen</code> failed. I have a simple check where if the pointer returned by <code>fopen</code> is <code>NULL</code> I conclude that the file was not opened successfully as per the description here: <a href="http://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.90).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.90).aspx</a></p>
  
  <p>The calling code in the project:</p>
  
  <pre><code>return fopen(a_fileName, "r"); // expected return to be NULL if the file can't be opened
  </code></pre>
  
  <p>Although at this point I can check <code>errno</code> but since the code is cross-platform, I am not sure whether I can rely on <code>errno</code>. But back to the original problem, why is <code>fopen</code> <em>not</em> returning <code>NULL</code>? See a screenshot below of <em>Visual C++ debugger</em>. </p>
  
  <p><img src="https://i.stack.imgur.com/Dg0Fs.png" alt="enter image description here"></p>
  
  <p>Note that the file actually exists but for some reason (which I am investigating now - decided to post this question before going ahead to see what the problem is as I may not be able to reproduce it) <code>fopen</code> fails to open the file. But again, why doesn't it return <code>NULL</code>?</p>
  
  <p>If this is normal behaviour, should I then write: </p>
  
  <pre><code>if (retFilePtr != NULL &amp;&amp; retFilePtr-&gt;_ptr != NULL) 
  {
    // do some stuff
  }
  </code></pre>