The function prototype for getchar() is: int
getchar(void);
It returns an int, not a char. In all likelihood this is specifically
*because* EOF is defined as -1.
It would have probably returned int anyway, because of the automatic
promotion of char to int in expressions. It was natural to declare
functions returning char as int, if you bothered to declare them at
all. As K&R1 said:
Since char promotes to int in expressions, there is no need
to declare functions that return char.
Similarly functions that might return short or float would normally
return int or double; there aren't separate atof and atod functions
for example.
-- Richard
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.