From cppreference.com
< c‎ | io
File input/output

File access
Direct input/output
Unformatted input/output
Formatted input
Formatted output
File positioning
Error handling
Operations on files
Defined in header <stdio.h>
int fflush( FILE *stream );

For output streams (and for update streams on which the last operation was output), writes any unwritten data from the stream's buffer to the associated output device.

For input streams (and for update streams on which the last operation was input), the behavior is undefined.

If stream is a null pointer, all open output streams are flushed, including the ones manipulated within library packages or otherwise not directly accessible to the program.


[edit] Parameters

stream - the file stream to write out

[edit] Return value

Returns zero on success. Otherwise EOF is returned and the error indicator of the file stream is set.

[edit] Notes

POSIX extends the specification of fflush by defining its effects on an input stream, as long as that stream represents a file or another seekable device: in that case the POSIX file pointer is repositioned to match the C stream pointer (which effectively undoes any read buffering) and the effects of any ungetc or ungetwc that weren't yet read back from the stream are discarded.

[edit] References

  • C11 standard (ISO/IEC 9899:2011):
  • The fflush function (p: 305)
  • C99 standard (ISO/IEC 9899:1999):
  • The fflush function (p: 270-271)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • The fflush function

[edit] See also

opens a file
closes a file
C++ documentation for fflush