Table of Contents
This guide covers function fflush ()() in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
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
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.