I have this very simple code:
#include <stdio.h>
#include <stdlib.h>
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;
}
Output:
Error!
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!".
What's going on??
I'm using Eclipse Neon.2 Release (4.6.2) with newest cygwin gcc compiler on Windows 10 64bit.
Thank you for your help!