Reputation: 3683
is EOF a special byte sequence that lies in the end of every file, or is it kinda exception(interrupt) that is notified by the kernel?
Upvotes: 2
Views: 672
Reputation: 126378
EOF is a special code returned by the C stdio library to denote that there's no more data to be read from a FILE
. Different operating systems have their own way of recording the size/end of a file and their own way of returning that to a user program, which will be translated into an EOF return code by the C standard library implementation on that operating system.
Upvotes: 0
Reputation: 16906
I've used the ASCII EOF character to separate data files into a human-readable header followed by binary data. This allowed everything the mechanical engineers needed from a test to be kept in one file, while keeping it small enough to fit a floppy. (This was years ago!) The EOF character told most text display programs to stop. Anyone wanting a quick peek at the file header could just use a "print" command (is that what it was?) in a command shell.
Mostly these days, the EOF character isn't used in files, at least in the small part of the world I inhabit. Practically none of the ASCII control characters have any use any more, beside NUL, ESC and CR/LF.
EOF may serve some purpose in some streaming protocols, but that's outside my expertise so I leave it to others to address that.
Upvotes: 1
Reputation: 799092
Long ago on DOS machines it used to be indicated by ^Z
, but nowadays it's the kernel reaching the end of the file and notifying the program when it tries to read further.
Upvotes: 11