fflush() - I/O Function

How is fflush() used in C++?


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.


int fflush ( FILE * stream );

Example :

#include <stdio.h>
int val;
int main(void)
FILE *str = fopen("test.txt", "w");
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.

C++ Tutorial

Ask Questions

Ask Question