On this page
fflush
Prev: ftell | Up: stdio.h | Next: feof
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — fflush
Tags: #public #prog #c #stdlib #stdio #tier/standard
Include
#include <stdio.h>
Signature & Overview
int fflush(FILE *stream);
Flushes buffered output data to the OS; fflush(NULL) flushes all open output streams.
Notes & Pitfalls
- Only flush output streams (or
NULLto flush all output streams): Callingfflush(stdin)is Undefined Behavior in standard C!
Example
#include <stdio.h>
int main(void) {
fputs("working...", stdout);
fflush(stdout); // ensure prompt appears immediately
}
Linked from
Related notes
- tuts/c/stdlib/stdio/feof Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ftell Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ferror shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fgets shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fprintf shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fputs shared tags: #c, #prog, #stdio, #stdlib, #tier