fclose(3s)fclose(3s)Name
fclose, fflush - close or flush a stream
Syntax
#include <stdio.h>
fclose(stream)
FILE *stream;
fflush(stream)
FILE *stream;
Description
The 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 routine is performed automatically upon calling
The 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 asso‐
ciated with an input file, the file pointer is positioned following the
last byte read from that stream.
See Alsoclose(2), fopen(3s), setbuf(3s)fclose(3s)