Related: fclose return value check
Although it's important to check the return value of fclose()
if you're writing a file (in case the flush operation fails), is it necessary to do so when reading a file?
FILE *f = fopen(path, "r");
if (f == NULL)
return 0;
/* Do something with the file... */
if (fclose(f) != 0) {
/* Error closing a file we successfully read. */
return 0;
}