EOF(3const)

✨ EOF β€” the end of the road, bestie ✨

okay so this is EOF, from section 3const of the manual (the "const" girlies, we love them πŸ’…). She lives in the Standard C library, aka libc, and she is literally the vibe of "that's all, nothing left, go home".


🌸 NAME 🌸

EOF β€” end of file or error indicator πŸ’–

she's not a character. she's a feeling. and also a number.

πŸ“š LIBRARY πŸ“š

Standard C library (libc) 🫢


πŸ“ SYNOPSIS πŸ“

#include <stdio.h>
#define EOF  /* ... */

like... it exists. that's the whole pitch ✨


πŸ’– DESCRIPTION πŸ’–

okay so listen. EOF represents the end of an input file, OR an error indication. either one. she's flexible like that πŸ’…

  • she is a negative value, and
  • her type is int.

and here's the part that makes her so iconic: EOF is not a character. she literally can't be represented by unsigned char. she's not like the other girls β€” she's a sentinel value that lives outside of the valid range for valid characters πŸ‘‘

so when you see her, it's not a letter, it's a signal. it's giving "this is over". it's giving "something went wrong". either way, you know πŸ¦‹


πŸŽ€ STANDARDS πŸŽ€

  • C11
  • POSIX.1-2024

certified. official. no cap ✨


🌈 HISTORY 🌈

  • C89
  • POSIX.1-1988

she's been here since forever, an OG, a legacy queen πŸ‘‘πŸ’œ


⚠️ CAVEATS ⚠️

right so this is the important part, bestie, pay attention πŸ™ˆ

Programs can't pass this value to an output function to "write" the end of a file. not a thing. don't try it.

attempting it would likely result in undefined behavior πŸ’€πŸ’€πŸ’€ like, actual UB. we do not do that here.

so what do you do instead? closing the writing stream, or closing the file descriptor that refers to such file β€” that is the way to signal the end of that file. that's it. that's the move. periodt 🫢


πŸ‘€ SEE ALSO πŸ‘€

go read those too, they're friends of hers, iykyk 🌸


mwah πŸ’‹ this page came from the Linux man-pages 6.20, dated 2026-01-05. stan stable docs, stan accurate docs, and stan closing your file descriptors properly πŸŽ€βœ¨πŸ¦‹

πŸ“¦ 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: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms