|
|
|
|
|
by andreyv
1569 days ago
|
|
In C, and many other languages, the file stream error state is saved after each operation, so you can skip error checking on every output line and only do if (fflush(stdout) != 0 || ferror(stdout) != 0)
{
perror("stdout");
return EXIT_FAILURE;
}
at the end of the program. The same should be done for stderr as well.In GNU programs you can use atexit(close_stdout) to do this automatically. |
|