Hacker News new | ask | show | jobs
by radarsat1 2804 days ago
How do you properly handle an error on fclose in C?
2 comments

At least without pretending that everything's OK. Report to user and abort process would be appropriate for many cases. Continuing work with half-written data without ever noticing it is not appropriate.
The same way you would handle an error on fwrite() or fflush(). Any of them failing means that the data wasn't written correctly; what to do with that depends on the program.