| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.\" |
| 6 |
.TH EOF 3const 2026-01-05 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
EOF \- end of file or error indicator |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <stdio.h> |
| 15 |
.P |
| 16 |
.BR "#define EOF " "/* ... */" |
| 17 |
.fi |
| 18 |
.SH DESCRIPTION |
| 19 |
.B EOF |
| 20 |
represents the end of an input file, or an error indication. |
| 21 |
It is a negative value, of type |
| 22 |
.IR int . |
| 23 |
.P |
| 24 |
.B EOF |
| 25 |
is not a character |
| 26 |
(it can't be represented by |
| 27 |
.IR "unsigned char" ). |
| 28 |
It is instead a sentinel value outside of the valid range for valid characters. |
| 29 |
.SH STANDARDS |
| 30 |
C11, POSIX.1-2024. |
| 31 |
.SH HISTORY |
| 32 |
C89, |
| 33 |
POSIX.1-1988. |
| 34 |
.SH CAVEATS |
| 35 |
Programs can't pass this value to an output function |
| 36 |
to "write" the end of a file. |
| 37 |
That would likely result in undefined behavior. |
| 38 |
Instead, |
| 39 |
closing the writing stream or file descriptor |
| 40 |
that refers to such file |
| 41 |
is the way to signal the end of that file. |
| 42 |
.SH SEE ALSO |
| 43 |
.BR feof (3), |
| 44 |
.BR fgetc (3) |