[<<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()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson