EOF(3const)

EOF3const

End of file or error indicator

Usage

#include <stdio.h>

#define EOF /* ... */

Library

Standard C library (libc)

Overview

EOF represents the end of an input file, or an error indication. It is a negative value, of type int.

EOF is not a character (it can't be represented by unsigned char). It is instead a sentinel value outside of the valid range for valid characters.

Caveats

Programs can't pass this value to an output function to "write" the end of a file. That would likely result in undefined behavior. Instead, closing the writing stream or file descriptor that refers to such file is the way to signal the end of that file.

Releases

3 releases since Debian 12 (Bookworm); the text changed 2 times.

  1. 12
  2. 13
  3. Arch

Standards

C11, POSIX.1-2024.

History

C89, POSIX.1-1988.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.