Chapter Contents |
Previous |
Next |
fflush |
Portability: | ISO/ANSI C conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
PORTABILITY | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
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:
fflush
has no effect. Passing the output buffer
to the operating system also forces a record break, which should occur only
when a new-line character is written.
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 |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.