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 π
C11POSIX.1-2024
certified. official. no cap β¨
π HISTORY π
C89POSIX.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