ⓘ End-of-file. In computing, end-of-file is a condition in a computer operating system where no more data can be read from a data source. The data source is usual ..

                                     

ⓘ End-of-file

In computing, end-of-file 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 Standard Library, the character reading functions such as getchar return a value equal to the symbolic value macro EOF to indicate that an end-of-file condition has occurred. The actual value EOF is implementation-dependent but is commonly -1, such as in glibc and is distinct from all valid character codes. Block-reading functions return the number of bytes read, and if this is fewer than asked for, then the end of file was reached or an error occurred checking of errno or dedicated function, such as ferror is often required to determine which.

                                     

1. EOF character

Input from a terminal never really "ends" unless the device is disconnected, but it is useful to enter more than one "file" into a terminal, so a key sequence is reserved to indicate end of input. In UNIX the translation of the keystroke to EOF is performed by the terminal driver, so a program does not need to distinguish terminals from other input files. By default, the driver converts a Control-D character at the start of a line into an end-of-file indicator. To insert an actual Control-D ASCII 04 character into the input stream, the user precedes it with a "quote" command character usually Control-V. AmigaDOS is similar but uses Control-\ instead of Control-D.

In DOS and Windows and in CP/M and many DEC operating systems such as RT-11 or VMS, reading from the terminal will never produce an EOF. Instead, programs recognize that the source is a terminal or other "character device" and interpret a given reserved character or sequence as an end-of-file indicator; most commonly this is an ASCII Control-Z, code 26. Some MS-DOS programs, including parts of the Microsoft MS-DOS shell COMMAND.COM and operating-system utility programs such as EDLIN, treat a Control-Z in a text file as marking the end of meaningful data, and/or append a Control-Z to the end when writing a text file. This was done for two reasons:

  • Backward compatibility with CP/M. The CP/M file system only recorded the lengths of files in multiples of 128-byte "records", so by convention a Control-Z character was used to mark the end of meaningful data if it ended in the middle of a record. The MS-DOS filesystem has always recorded the exact byte-length of files, so this was never necessary on MS-DOS.
  • It allows programs to use the same code to read input from both a terminal and a text file.

In the ANSI X3.27-1969 magnetic tape standard, the end of file was indicated by a tape mark, which consisted of a gap of approximately 3.5 inches of tape followed by a single byte containing the character 13 hex for nine-track tapes and 17 octal for seven-track tapes. The end-of-tape, commonly abbreviated as EOT, was indicated by two tape marks. This was the standard used, for example, on IBM 360. The reflective strip that was used to announce impending physical end of tape was also called an EOT marker.

                                     
  • keep track of the file size in bytes, the end of a text file is denoted by placing one or more special characters, known as an end - of - file marker, as
  • Its most common use today is to cause a Unix terminal driver to signal end of file and thus exit programs that are awaiting input. In ASCII and Unicode
  • end of text files The general definition of a file does not require that its size have any real meaning, however, unless the data within the file happens
  • one end to which a handle may be fitted. A rasp is a form of file with distinct, individually cut teeth used for coarsely removing large amounts of material
  • ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or directories that may have been compressed
  • In computing, a file system or filesystem often abbreviated to fs controls how data is stored and retrieved. Without a file system, data placed in a
  • contexts, a file sequence is a well - ordered, finite collection of files usually related to each other in some way. In computing, file sequences should
  • binary file is a computer file that is not a text file The term binary file is often used as a term meaning non - text file Many binary file formats
  • File sharing is the practice of distributing or providing access to digital media, such as computer programs, multimedia audio, images and video documents
  • File formats may be either proprietary or free and may be either unpublished or open. Some file formats are designed for very particular types of data:
  • computing, file system fragmentation, sometimes called file system aging, is the tendency of a file system to lay out the contents of files non - continuously