I am using C to open a file for reading. I have this code :
fp = fopen("./settings.cfg","r");
if (fp != NULL)
printf("OK");
else
printf("ERROR");
but I always get an error.
The file is located in the folder where the executable resides. I have tried writing only “settings.cfg”. What might be the problem?
Try
perror()to have the library itself tell you what, if anything, is wrong.