Steve wrote:
Is it allowed to fclose stdin?
Trying it here it seems to work ok, but it occurs to me that on some other
system the standard library might call fclose(stdin) during its clean up,
and calling fclose twice (on normal streams at least) gives undefined
behaviour.
The Standard doesn't appear to prohibit closing stdin
(or stdout and stderr, for that matter, except that the
behavior of perror() and assert() becomes problematic if
stderr is closed).
The Standard also doesn't say that stdin/out/err get
closed during program termination; it says that *all* open
streams get closed, and doesn't make a special case for
these three. Perhaps that's a suggestive omission.
--
Er*********@sun.com