Main Page | See live article | Alphabetical index

End-of-file

End-of-file, commonly abbreviated EOF, is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream.

In the C programming language, or more correctly, the C Standard Library, file access and other I/O functions may return a value equal to the symbolic value (macro) EOF to indicate that an end-of-file condition has occurred. The actual value of EOF is commonly -1, but is system-dependent. The macro EOF is expanded to the actual value by a preprocessor before compiling the source code.

In UNIX an end-of-file indication can be sent from an interactive shell (console) by typing Ctrl+D (conventional standard). In Microsoft's DOS it is sent by pressing Ctrl+Z. Microsoft historically appended an ASCII Control-Z character to the end of a file, presumably because the original versions of the MSDOS operating system were not capable of detecting an end-of-file condition otherwise.

ASCII control characters are out-of-band non-printing characters in a character stream. They are normally represented by a more readable mnemonic.