std::fflush(3)
π std::fflush π
okay bestie, you're looking at the std::fflush(3) page from the C++ Standard Libary (yes, that's the header's spelling, and no, we're not fixing it π
). we're talking about flush today, and it's lowkey iconic.
πΈ NAME πΈ
std::fflushβstd::fflush(yes bestie, self-titled, we love that for it β¨)
β¨ Synopsis β¨
Defined in header <cstdio>
int fflush( std::FILE* stream );
For output streams (and for update streams on which the last operation was output), it 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. π
β οΈ bestie, that undefined behavior is not a cute little quirk β it's literally undefined, so don't roll the dice on it, fr fr.
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. π
π Parameters π
streamβ the file stream to write out π«Ά
π₯ Return value π₯
Returns zero on success. Otherwise EOF is returned and the error indicator of the file stream is set. πβ¨
π¦ 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 std::ungetc or std::ungetwc that weren't yet read back from the stream are discarded. π
Microsoft also extends the specification of fflush by defining its effects on an input stream: in Visual Studio 2013 and prior, it discarded the input buffer; in Visual Studio 2015 and newer, it has no effect, buffers are retained. πͺ
π See also π
fopenβ opens a file (function) ποΈfcloseβ closes a file (function) πͺ- C documentation for
fflushπ
okay bye bestie, mwah π β source/version is http://cppreference.com, dated 2024.06.10, on page std::fflush(3) π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms