<P> 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 . </P> <P> In Microsoft's DOS and Windows (and in CP / M and many DEC operating systems), 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: </P> <Ul> <Li> 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 . </Li> <Li> It allows programs to use the same code to read input from both a terminal and a text file . </Li> </Ul> <Li> 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 . </Li>

What is end of file character in c++