fflush
Syntax:
#include <cstdio> int fflush( FILE *stream );
If the given file stream is an output stream, then fflush() causes the output buffer to be written to the file.
If the given stream is of the input type, then the behavior of fflush() is undefined.
fflush() is useful when debugging, if a program segfaults before it has a chance to write output to the screen. Calling fflush(stdout) directly after debugging output will ensure that your output is displayed at the correct time.
printf( "Before first call\n" ); fflush( stdout ); shady_function(); printf( "Before second call\n" ); fflush( stdout ); dangerous_dereference();
See also: http://c-faq.com/stdio/stdinflush.html
Related Topics: fclose, fopen, fread, fpurge, fwrite, getc, putc