fflush(3)

โœจ fflush(3) โ€” Library Functions Manual โœจ

okay bestie, welcome to the fflush(3) page, it's giving "library functions manual" energy and honestly? iconic. ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

fflush โ€” flush a stream ๐Ÿ’…


๐ŸŽ€ LIBRARY ๐ŸŽ€

Standard C library (libc, -lc) โ€” she's built in, no extra shopping required ๐Ÿซถ


โœจ SYNOPSIS โœจ

#include <stdio.h>

int fflush(FILE *_Nullable stream);

that's it. that's the whole vibe check. one function, one argument, go off queen ๐Ÿ‘‘


๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so for output streams, fflush() forces a write of all user-space buffered data for the given output or update stream, and it does it via the stream's underlying write function. like, everything hanging out in the buffer? out the door. flushing it. periodt. ๐Ÿšฝโœจ

for input streams that are associated with seekable files (think disk files, but NOT pipes or terminals, she's picky), fflush() discards any buffered data that has been fetched from the underlying file but has not been consumed by the application. yeah, it just throws it away bestie, that data said bye ๐Ÿ™ˆ

the open status of the stream is unaffected. it's still open, still valid, still that girl. no cap.

if the stream argument is NULL, fflush() flushes all open output streams. all of them. every single one. group-chat announcement energy ๐Ÿ“ข

for a nonlocking counterpart, see unlocked_stdio(3) โ€” iykyk ๐Ÿ‘€


โญ RETURN VALUE โญ

upon successful completion, 0 is returned. slay. ๐ŸŽ‰

otherwise, EOF is returned and errno is set to indicate the error. not slay. ๐Ÿ˜ญ


๐Ÿ’€ ERRORS ๐Ÿ’€

  • EBADF โ€” stream is not an open stream, or is not open for writing. like girl, that's not a stream, or it's not even open for writing, what are you doing ๐Ÿ™ˆ

also, fflush() may fail and set errno for any of the errors specified for write(2) โ€” so go check that page too, she's got receipts.


๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

for an explanation of the terms used in this section, see attributes(7).

  • Interface: fflush()
  • Attribute: Thread safety
  • Value: MT-Safe

(she's MT-Safe, she can hang with the whole group at once, no drama ๐Ÿ’…)


๐ŸŒˆ STANDARDS ๐ŸŒˆ

C11, POSIX.1-2008.


๐Ÿฆ‹ HISTORY ๐Ÿฆ‹

C89, POSIX.1-2001, POSIX.1-2008.

and a lil lore drop: POSIX.1-2001 did not specify the behavior for flushing of input streams, but the behavior is specified in POSIX.1-2008. so if you're on the old spec, no promises, bestie ๐Ÿซ 


๐Ÿ“ NOTES ๐Ÿ“

note that fflush() flushes only the user-space buffers provided by the C library. it does NOT make your data physically hit the disk. ๐Ÿ›‘

to ensure the data is physically stored on disk, the kernel buffers must be flushed too โ€” for example, with sync(2) or fsync(2). two-step process, don't skip leg day fr fr ๐Ÿ‹๏ธโ™€๏ธ


๐Ÿงš SEE ALSO ๐Ÿงš

fsync(2), sync(2), write(2), fclose(3), fileno(3), fopen(3), fpurge(3), setbuf(3), unlocked_stdio(3)


and that's the whole page, bestie ๐ŸŽ€ this was Linux man-pages version 6.20, dated 2025-05-17, and she ate and left no crumbs. go flush something. responsibly. ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: BSD-4-Clause-UC
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms