Various references
- Always check return value
- Error handling in C is primitive
catchandthrow- C/Unix return value examples
- C/Unix error handling aids
- CERT recommentations
- Secure Coding in C and C++
The code you should write
FILE *filePtr = fopen(fileName, "w") ;
if (filePtr == NULL) {
printf("open of %s failed: %s\n", fileName, strerror(errno)) ;
return 1 ;
}