Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>fflush</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fflush

Usage

   #include <stdio.h>
   int fflush(FILE *fp);

   ANSI

Description

   Flushes the buffer associated with stream fp. If the file is opened for
   writing, the buffer is written. If the file is opened for reading, the
   buffer is cleared.

   The fflush function may be used to force the data in the file buffer to
   be written to the file before the buffer becomes full. Similarly data
   read from a file is input a buffer full at a time. Only after every
   character has been processed does another file access occur. The fflush
   function may be used to clear the buffer and thus force the next read
   operation to occur.

Example 

   #include <stdio.h>
   #include <stdlib.h>

   FILE *fp;

   int main()
   {
       if((fp = fopen("file.dat","w"))==NULL)
            return EXIT_FAILURE;
       fflush(fp); /* flush buffer to disk to protect   */
                       /* data before performing operations */
                       /* that may cause system crash      */

       return EXIT_SUCCESS;
   }

Return Value

   fflush returns a 0 if the buffer was successfully flushed. EOF is
   returned if an error occurred.

See Also

   fclose, fclose, flushall


See Also: fclose fclose flushall

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson