After opening a file, you should always check to ensure that the FILE pointer was returned successfully.
In other words, you want to check for occasions when the specified file name cannot be found.
To test fopen()’s return value, test for a NULL value in a condition, as demonstrated next.