Using the value of a pointer to a FILE
object after the associated file is closed is undefined behavior. (See undefined behavior 148153.) Programs that close the standard streams (especially stdout
but also stderr
and stdin
) must be careful not to use these streams in subsequent function calls, particularly those that implicitly operate on them (such as printf()
, perror()
, and getc()
).
...