title: C - Why fopen doesn't work?
body: <p>I have this very simple code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main (void)
      {
      FILE * file_ptr = NULL;
  
      file_ptr = fopen ("file.txt", "r");
  
      if (file_ptr == NULL)
          {
          puts ("Error!");
          return EXIT_FAILURE;
          }
      else
          {
          puts ("O.k.!");
          }
  
      return EXIT_SUCCESS;
      }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>Error!
  </code></pre>
  
  <p>Why fopen doesn't work? The file is not protected, not opened elsewhere and is stored in the same folder as the *.exe of this program. I also tried it with giving the complete path to the file and with an array, in which the filename is stored. Everytime it puts out "Error!".</p>
  
  <p>What's going on??</p>
  
  <p>I'm using Eclipse Neon.2 Release (4.6.2) with newest cygwin gcc compiler on Windows 10 64bit.</p>
  
  <p>Thank you for your help!</p>