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 6.0 - <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


    fflush() flushes the contents of the buffer associated with 'stream'.
    If 'stream' is open for output, the buffer's contents are written to
    the file; if 'stream' is open for input, the buffer contents are
    cleared.  After the call, 'stream' remains open.

    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:    A stream that is not buffered is not affected by
                fflush().

                Flushing occurs automatically if buffers are full, the
                stream is closed, or a program terminates normally.

                fflush() negates the effect of any prior ungetc() against
                'stream'.

   -------------------------------- 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[BUFSIZ];

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


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

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