Function Name: fflush
Function: clears a stream.
Usage: int fflush (File * stream );
Program example:
# Include <string. h>
# Include <stdio. h>
# Include <conio. h>
# Include <Io. h>
Void flush (File * stream );
Int main (void)
{
File * stream;
Char MSG [] = "this is a test ";
/* Create a file */
Stream = fopen ("dummy. fil", "W ");
/* Write some data to the file */
Fwrite (MSG, strlen (MSG), 1, stream );
Clrscr ();
Printf ("press any key to flush/
Dummy. fil :");
Getch ();
/* Flush the data to dummy. fil/
Closing it */
Flush (Stream );
Printf ("/nfile was flushed, press any key/
To quit :");
Getch ();
Return 0;
}
Void flush (File * Stream)
{
Int duphandle;
/* Flush the stream's internal buffer */
Fflush (Stream );
/* Make a duplicate file handle */
Duphandle = DUP (fileno (Stream ));
/* Close the duplicate handle to flush/
The dos buffer */
Close (duphandle );
}