You can do man fopen - it says Upon successful completion fopen() return a FILE pointer. Otherwise, NULL is returned and errno is set to indicate the error.
Please check whether the file exists in the execution path or in your program, check the errno