Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
End-of-file
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Offset that corresponds to the first byte beyond the length of a computer file}} {{use dmy dates|date=November 2021|cs1-dates=y}} {{use list-defined references|date=December 2021}} In [[computing]], '''end-of-file''' ('''EOF''')<ref name="Pollock"/> 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 (computing)|file]] or [[stream (computing)|stream]]. ==Details== In the [[C standard library]], the character-reading functions such as [[getchar]] return a value equal to the symbolic value (macro) <code>EOF</code> to indicate that an end-of-file condition has occurred. The actual value of <code>EOF</code> is implementation-dependent and must be negative (it is commonly β1, such as in [[glibc]]<ref name="GNU-C"/>). 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 <code>[[errno]]</code> or dedicated function, such as <code>ferror</code> is required to determine which). ==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|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 [[End-of-transmission character|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 [[Microsoft Windows|Windows]] (and in [[CP/M]] and many [[Digital Equipment Corporation|DEC]] operating systems such as the [[PDP-6]] monitor,<ref name="DEC_1965_PDP-6"/> [[RT-11]], [[OpenVMS|VMS]] or [[TOPS-10]]<ref name="DEC_1970_PDP-10"/>), 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]] [[Substitute character|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]] (and also the original [[8-bit FAT]] implemented in [[Microsoft BASIC]]) 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 [[FAT12]] filesystem introduced with [[86-DOS]] and MS-DOS has always recorded the exact byte-length of files, so this was never necessary on DOS. * It allows programs to use the same code to read input from both a terminal and a text file. {{anchor|tape mark}} <!-- "Tape mark" redirects to the above anchor --> {{anchor|EOT}} <!-- "EOT" redirects to the above anchor --> In the ANSI X3.27-1969 [[magnetic tape data storage|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 <code>0x13</code> (hex) for [[9-track tape|nine-track tapes]] and <code>017</code> (octal) for [[IBM 7-track|seven-track tapes]].<ref name="MARC21_1977"/> 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 [[9-track tape#Technical details|reflective strip]] that was used to announce impending physical end of tape was also called an '''EOT''' marker. ==See also== * [[End-of-Transmission character]] (EOT) * [[Substitute character]] * [[End of message]] * [[Here document]] * [[-30-]] ==References== {{reflist|refs= <ref name="Pollock">{{cite web |title=Shell Here Document Overview |publisher=hccfl.edu |author-first=Wayne |author-last=Pollock |url=http://content.hccfl.edu/pollock/ShScript/HereDoc.htm |access-date=2014-05-28 |url-status=dead |archive-url=https://web.archive.org/web/20140529084958/http://content.hccfl.edu/pollock/ShScript/HereDoc.htm |archive-date=2014-05-29}}</ref> <ref name="GNU-C">{{cite web |title=The GNU C Library |website=www.gnu.org |url=https://www.gnu.org/software/libc/manual/html_mono/libc.html#EOF-and-Errors}}</ref> <ref name="DEC_1965_PDP-6">{{cite book |title=PDP-6 Multiprogramming System Manual |chapter=Table of IO Device Characteristics - Console or Teletypewriters |id=DEC-6-0-EX-SYS-UM-IP-PRE00 |publisher=[[Digital Equipment Corporation]] (DEC) |publication-place=Maynard, Massachusetts, USA |date=1965 |page=43 |url=http://bitsavers.trailing-edge.com/pdf/dec/pdp6/DEC-6-0-EX-SYS-UM-IP-PRE00_Multiprogramming_System_Manual_1965.pdf |access-date=2014-07-10 |url-status=live |archive-url=https://web.archive.org/web/20140714140253/http://bitsavers.trailing-edge.com/pdf/dec/pdp6/DEC-6-0-EX-SYS-UM-IP-PRE00_Multiprogramming_System_Manual_1965.pdf |archive-date=2014-07-14}} (1+84+10 pages)</ref> <ref name="DEC_1970_PDP-10">{{cite book |title=PDP-10 Reference Handbook: Communicating with the Monitor - Time-Sharing Monitors |volume=3 |chapter=5.1.1.1. Device Dependent Functions - Data Modes - Full-Duplex Software A(ASCII) and AL(ASCII Line) |publisher=[[Digital Equipment Corporation]] (DEC) |date=1969 |pages=5-3 β 5-6 [5-5 (431)] |url=http://bitsavers.org/pdf/dec/pdp10/1970_PDP-10_Ref/1970PDP10Ref_Part3.pdf |access-date=2014-07-10 |url-status=live |archive-url=https://web.archive.org/web/20111115083418/http://www.bitsavers.org/pdf/dec/pdp10/1970_PDP-10_Ref/1970PDP10Ref_Part3.pdf |archive-date=2011-11-15}} (207 pages)</ref> <ref name="MARC21_1977">{{cite web |title=Tape Transfer (Pre-1977): Exchange Media: MARC 21 Specifications for Record Structure, Character Sets, and Exchange Media (Library of Congress) |website=www.loc.gov |url=https://www.loc.gov/marc/specifications/specexchtape2.html#mark}}</ref> }} [[Category:C standard library]] [[Category:Computer files]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Use list-defined references
(
edit
)