On 2012-02-19, at 13:47, Abby Cedar wrote: >> Am I missing something? Why not just use flose(stdout)? > > Using only fclose would result in Bad file descriptor errors on future > attempts to write to stdout. freopen is cleaner.
And so it becomes a philosophical question. When you close a file descriptor, it's because you're not going to use it any more. If the programmer forgets and writes to stdout anyway, is it better to have the program exit with an error, or to hide the problem so that nobody discovers the bug? -Truls