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);
                }
          }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster