Syntax
#include <stdio.h> int _flushall(void);Description
For portability, use the ANSI/ISO function fflush instead of _flushall.
In this example, _flushall completes any pending input or output on all streams by flushing all buffers.
#include <stdio.h>
int main(void)
{
int i,numflushed;
char buffer1[5] = { 1,2,3,4 };
char buffer2[5] = { 5,6,7,8 };
char *file1 = "file1.dat";
char *file2 = "file2.dat";
FILE *stream1,*stream2;
stream1 = fopen(file1, "a+");
stream2 = fopen(file2, "a+");
for (i = 0; i <= sizeof(buffer1); i++) {
fputc(buffer1[i], stream1);
fputc(buffer2[i], stream2);
}
numflushed = _flushall(); /* all streams flushed */
printf("Number of files flushed = %d\n", numflushed);
fclose(stream1);
fclose(stream2);
return 0;
/****************************************************************************
The output should be:
Number of files flushed = 5
****************************************************************************/
}
Related Information