Is it permissible in C89 to do an "fclose(stdout)"
and then exit, or is the C runtime library allowed to
assume that stdout remains open and thus unconditionally
do an fclose itself?
Thanks. Â Paul.
In C99, you can do that. But I am not familar with C89, I can't promise
C89 also allows you to do that. I don't know why you are care for C89.
In fact, you can find the following rules in C99:
(1)
At program startup, three text streams are predeï¬ned and need not be
opened explicitly— standard input (for reading conventional input),
standard output (for writing conventional output), and standard error
(for writing diagnostic output).
(2)
If the main function returns to its original caller, or if the exit
function is called, all open ï¬les are closed (hence all output
streams are flushed) before program termination.