EOF Is Not a Character
ruslanspivak.com
ruslanspivak.com
Also, Unix terminal drivers commonly treat the EOT (end-of-transmission, ASCII 4, ^D) character specially and generate an EOF condition in response to a user input containing EOT. This creates an especially challenging situation for beginners to understand because, while EOF is not a character, there is a character at another layer that sometimes causes an EOF condition—yet that character itself is neither EOF, nor equivalent to EOF, nor guaranteed to cause EOF in every circumstance. (Also, the EOT character's behavior in this regard can be changed with the stty command, and it can be input as an ordinary character from a terminal by first escaping it with ^V...)