A file may be disassociated from a controlling stream by closing the file. Output streams are flushed (i.e. the unwritten buffer contents are transmitted) before the stream is disassociated from the file. The value of a pointer to a FILE
object is indeterminate after the associated file is closed (including the standard streams).
A file may be subsequently reopened by the same or another program, and its contents may be reclaimed or modified (if the file can be repositioned at its start). If the main
function returns to its original caller, or if the exit
function is called, all output streams are flushed and all open files are closed before program termination. Other methods of program termination, such as calling abort
, may not close all files properly.
The address of the FILE
object used to control a stream may be significant; a copy of a FILE
object may not necessarily serve in place of the original.