fflush -- Flush Output Buffer

SYNOPSIS

 #include <stdio.h>

 int fflush(FILE *f);
 

DESCRIPTION

fflush flushes the output buffer for the stream associated with the FILE object addressed by f. The exact effect of fflush depends on the file type and stream type, as follows:

If you do not use fflush, output buffers are flushed as follows:

The effect of fflush on a read-only file is undefined.

RETURN VALUE

fflush returns 0, or EOF if an error occurs.

PORTABILITY

fflush is portable when used to ensure that output to an interactive device is written out. The use of fflush on other files, such as disk files, does not guarantee immediate I/O, and using fflush to force record breaks is completely nonportable.

EXAMPLE

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

  main()
  {
     long partno;

     fputs("Enter part number:", stdout);
     fflush(stdout);     /* Force prompt to terminal. */
     scanf("%ld", &partno);  /* Read the part number. */
     ptintf("Request for part # %ld received.", partno);
  }

 

RELATED FUNCTIONS

afflush, fsync

SEE ALSO


Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.