Recently faced with an interesting interpretation of the EOF character console windows. On some machines running windows 7 code putchar (255)
&& putchar (-1)
is displayed as a space character, and some as 'a'
character. The second confuses me. Tell me please, why is this happening?
EOF
is not a character, it's more like a signal (not the Unix signal) indicating End-of-File. Is value is implementation dependent, but guaranteed to be unequal to any valid character, usually -1
.
When you use putchar(EOF)
, or putchar(-1)
, it's converted to unsigned char
, 255
. But the ASCII value 255
isn't a printable character, the result varies in different machines.