I\'m programming C on Windows(system language is Japanese), and I have a problem about EOF of binary and ascii files.
I asked this question last week, a kind guy help
This is a Windows-specific trick for text files: SUB
character, which is represented by Ctrl+Z sequence, is interpreted as EOF
by fgetc
. You do not have to have 1A
in your text file in order to get an EOF
back from fgetc
, though: once you reach the actual end of file, EOF
would be returned.
The standard does not define 1A
as the char
value to represent an EOF
. The constant for EOF
is of type int
, with a negative value outside the range of unsigned char
. In fact, the reason why fgetc
returns an int
, not char
, is to let it return a special value for EOF
.