fclose(3s)
Name
fclose, fflush − close or flush a stream
Syntax
#include <stdio.h>
fclose(stream)
FILE *stream;
fflush(stream)
FILE *stream;
Description
The fclose routine causes any buffers for the named stream to be emptied, and the file to be closed. Buffers allocated by the standard input/output system are freed. The fclose routine is performed automatically upon calling exit.
The fflush routine causes any buffered data for the named output stream to be written to that file. If stream is NULL, all open output streams are flushed. The stream remains open.
Diagnostics
These functions return EOF if buffered data cannot be transferred to an output stream.
Environment
If not called in POSIX mode, these functions return EOF if stream is not associated with an output file. In POSIX mode, if stream is associated with an input file, the file pointer is positioned following the last byte read from that stream.