I'm writing a C program, and I'm curious about something. The program has several functions that return 1 on success and 0 on failure, and most are called by main()
(though some are called by other functions). This is for an assignment, and if an error is caught I need to print the error to stderr
using fprintf()
and terminate the program.
What is the proper way to handle error termination? Should I allow the function to print to stderr
, then return 1 back to main()
then have main()
actually terminate, or should the function itself handle error printing and program termination?