fflush

flush the input or output buffer for a file

Synopsis:

#include <stdio.h>
int fflush( FILE *fp );

Description:

If the file fp is open for output or update, the fflush() function causes any unwritten data to be written to the file. If the file fp is open for input or update, the fflush() function undoes the effect of any preceding ungetc operation on the stream. If the value of fp is NULL, then all files that are open will be flushed.

Returns:

0
Success
(-1)
An error occurred. errno is set to indicate the error.

See also:

errno, fgetc(), fgets(), flushall(), fopen(), getc(), gets(), setbuf(), setvbuf(), ungetc()

Examples:

#include <stdio.h>
#include <conio.h>

void main()
  {
    printf( "Press any key to continue..." );
    fflush( stdout );
    getch();
  }

Classification:

ANSI

Systems:

All (except DOS/PM)