Syntax
#include <stdio.h> int fflush(FILE *stream);Description
fflush causes the system to empty the buffer associated with the specified output stream, if possible. If the stream is open for input, fflush undoes the effect of any ungetc function. The stream remains open after the call.
If stream is NULL, the system flushes all open streams.
Note: The system automatically flushes buffers when you close the stream, or when a program ends normally without closing the stream.
fflush returns the value 0 if it successfully flushes the buffer. It returns EOF if an error occurs.
This example flushes a stream buffer.
#include <stdio.h> int main(void) { FILE *stream; stream = fopen("myfile.dat", "w"); fprintf(stream, "Hello world"); fflush(stream); fclose(stream); return 0; }Related Information