Function fflush () in C
The int fflush function (FILE * stream) in Library C flushes the output buffer of a Stream.
The int fflush function (FILE * stream) in Library C flushes the output buffer of a Stream.
Declare the function fflush () in C
Below is the declaration for fflush () function in C:
int fflush ( FILE * stream )
Parameters
stream - This is a pointer to a FILE object that identifies a Stream buffered.
Returns the value
This function returns a value of 0 if successful. If there is an error, the EOF is returned and the Error Indicator is set (feof example).
For example
The following C program illustrates the usage of the fflush () function in C:
#include #include int main () { char buff [ 1024 ]; memset ( buff , '' , sizeof ( buff )); fprintf ( stdout , "Chuan bi buffern" ); setvbuf ( stdout , buff , _IOFBF , 1024 ); fprintf ( stdout , "Hoc C co ban va nang cao tai QTM !!!n" ); fprintf ( stdout , "Ket qua nay se duoc demn" ); fflush ( stdout ); return ( 0 ); }
Compiling and running the above program will produce the following results. Here, the program still buffers the output into the buff until it encounters the first call to the fflush () function, then it starts buffering output.
According to Tutorialspoint
Previous lesson: ferror () function in C
Next lesson: Function fgetpos () in C
You should read it
- Function vfprintf () in C
- The function setvbuf () in C
- The sprintf () function in C
- Remove () function in C
- Function setbuf () in C
- The ferror () function in C
- The function fsetpos () in C
- Function fwrite () in C
- Function fseek () in C
- The function fgetpos () in C
- Function ftell () in C
- The function fread () in C
Maybe you are interested
Admire the colorful moment of a star in the making The whole scene of meteorites hitting the Earth during the past 33 years, why can't we feel it? The most beautiful meteor shower of the year and amazing astronomical phenomena in August Science has discovered the fastest-flying star in the Milky Way, reaching 8% of the speed of light Macromedia Flash - Zoom in / Zoom out with the button The Kepler Space Telescope is about to stop operating in the next few months