fclose, fflush, fpurge - close or flush a stream

#include <stdio.h>

int fclose(stream)
FILE *stream;

int fflush(stream)
FILE *stream;

int fpurge(stream)
FILE *stream;

Fclose 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.

Fclose is performed automatically upon calling exit(3).

Fflush causes any buffered data for the named output stream to be
written to that file. The stream remains open.

Fpurge erases any input or output buffered in the given stream.
For output streams this discards any unwritten output. For input
streams this discards any input read from the underlying object byt
not yet obtained via getc(3); this includes any text pushed back
via ungetc(3).

close(2), fopen(3), setbuf(3)

These routines return EOF if stream is not associated with an
output file, or if buffered data cannot be transferred to that