- Fflush
fflush is a C function belonging to the
ANSI C standard library , and included in the filestdio.h . Its purpose is to write any buffered output data for the specified stream.Function prototype
:
int fflush(FILE "*stream_pointer");
Argument meaning:
* "stream_pointer" is either a pointer to the output stream for which the buffered data is to be written, or "NULL". If "NULL" is passed as an argument fflush flushes all opened output streams.Return value
The return value is an "integer" which means:
* "0" (zero) : function performed successfully in the stream.
* "EOF" : an error occurred anderrno is set.Note that each error number has a distinct meaning. The meaning can usually be revealed by checking "
errno.h "; the strerror() function converts an error number to a descriptive text string.Remarks
* The "fflush" function is usually used to prevent data loss by ensuring that the data is written to stream
* It should be used for output streams only; otherwise the behavior is undefined.
* Often "fflush" is used on the standard output stream becausestdout is usually buffered and the output might not be prompted immediately.
* A call tofclose will flush the stream.
* A null argument did not have defined behavior in older implementations of the C library.Example
This program code creates a file called "text.txt" and writes 100 strings of the form "Line
" to it, flushing the buffer after each write. External links
* [http://c-faq.com/stdio/stdinflush.html comp.lang.c FAQ list · Question 12.26a]
*See also
*
fclose
*setvbuf
Wikimedia Foundation. 2010.