[Previous] [Contents] [Next]

fflush()

Flush the buffers for a stream

Synopsis:

#include <stdio.h>

int fflush( FILE* fp );

Library:

libc

Description:

If the stream specified by fp is open for output or update, the fflush() function causes any buffered (see setvbuf()) but unwritten data to be written to the file descriptor associated with the stream (see fileno()).

If the file specified by fp is open for input or update, the fflush() function undoes the effect of any preceding ungetc operation on the stream.

If fp is NULL all open streams are flushed.

Returns:

0 for success, or EOF if an error occurs (errno is set).

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
    printf( "Press Enter to continue..." );
    fflush( stdout );
    getchar();

    return EXIT_SUCCESS;
}

Classification:

ANSI

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

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


[Previous] [Contents] [Next]