You might be surprised at the warnings you'd get. Did you know, for example, that printf returns a value? It's also a return value that rarely, if ever, tends to be useful.
int written = printf("Got here");
if (written != sizeof("Got here") - 1) {
written = fprintf(stderr, "Could not print my sacred message\n");
if (written != sizeof("Could not print my sacred message\n") - 1) {
exit(I_DONT_KNOW_WTF_IS_HAPENNING_HERE);
}
}You made a small mistake, since fprintf and printf call the same underlying code, the error handling should be either log the error in any way still available, and then depending on the design of the whole program, exit or continue. If printf fails you know exactly what is going on or have to exit. ( And printf would be wrapped in a function if you plan to use it repeatedly. )