Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo 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


    fflush() flushes the contents of a buffer associated with an open
    input or output stream. If 'stream' is open for input, fflush()
    clears the contents of the buffer and leaves the stream open. If
    'stream' is open for writing, fflush() causes the buffer contents to
    be written to the file, and leaves the file open.

       Returns:     0, 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[BUFSIZ];

           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