Function return types are useful for returning values that indicate if the function did what it was supposed to do.
However if error handling is done within the function (for example fprintf(stderr, errormessage)
and exit(EXIT_FAILURE)
) that means one could define a function with the void
return type instead.
So my question is: is it bad practice in C to have a program with multiple functions with void
return types while handling errors in the way stated above in contrast to returning a number?
I ask because I am writing a program and noticed my header files look like this and each function uses printing to stderr
and exit()
:
void function1();
void function2();
void function3();
void function4();
void function5();
void function6();
void function7();
void function8();
void function9();