Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>fflush() flush a stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fflush()                 Flush a Stream

 #include   <stdio.h>

 int        fflush(stream);
 FILE       *stream;                     Pointer to file structure


    If 'stream' is open for writing, fflush() causes the contents of
    'stream's buffer to be written to the file.  If 'stream' is open for
    input, the buffer contents are cleared.  The 'stream' remains open
    after the call.

    Returns:    Zero if the buffer was successfully flushed, the stream
                has no buffer, or the stream is open for reading only.
                EOF is returned on error.

      Notes:    fflush() has no effect on an unbuffered stream.

                Buffers are automatically flushed when they are full, the
                stream is closed, or a program terminates normally.

  -------------------------------- Example ---------------------------------

    This example opens a file, flushes the stream's buffer, then sets up
    a user-assigned buffer.

         #include <stdio.h>

         FILE *stream;
         char buf[BUFSIZE];

         main()
         {
              if ((stream = fopen("yrend.dat","r+")) != NULL) {
                  fflush(stream);
                  setbuf(stream,buf);
                }
          }

See Also: flushall() fclose() setbuf()

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