|
|
Tutorials

Cpp

|
Topic |
How is fflush() used in C++?
|
|
Explanation |
|
When a stream associated with a file is opened for writing the fflush(), I/O function physically writes the
content of the output buffer to a file. If the value returned is "0" for success, EOF indicates a write error.
Syntax:
int fflush ( FILE * stream );
Example:
|
#include <stdio.h>
int val;
int main(void)
{
FILE *str = fopen("test.txt", "w");
val=fflush(str);
printf("Return value for fflush is: %i",val);
}
|
Result:
Return value for the fflush is:0
In the above example the fflush() is returns 0, which indicates the output buffer is flushed successfully.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|