fflush(), fpurge() - flush a stream
#include <stdio.h>
int fflush (FILE *stream)
int fpurge (FILE *stream)
The function fflush(3) forces a write of all buffered data for the given output or update stream through the stream's underlying write function. The open status of the stream is unaffected.
If the stream argument is NULL, fflush(3) flushes all open output streams.
The function fpurge(3) 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 but not yet obtained through getc(3); this includes any text pushed back through ungetc(3).
Upon successful completion the functions return 0. Otherwise, they return EOF and set the global variable errno to indicate the error.
Fflush(3) can also fail for any of the reasons associated with the write(2) function.
fclose(3)
fopen(3)
setbuf(3)
write(2)