standard C lib:
int fputc(int c , FILE *stream);
And such behaviors occured many times, e.g:
int putc(int c, FILE *stream);
int putchar(int c);
why not use CHAR as it really is?
If use INT is necessary, when should I use INT instead of CHAR?
Most likely (in my opinion, since much of the rationale behind early C is lost in the depths of time), it it was simply to mirror the types used in the
fgetctype functions which must be able to return any real character plus theEOFspecial character. Thefgetcfunction gets the next character converted to anint, and uses a special marker valueEOFto indicate the end of the stream.To do that, they needed the wider
inttype since acharisn’t quite large enough to hold all possible characters plus one more thing.And, since the developers of C seemed to prefer a rather minimalist approach to code, it makes sense that they would use the same type, to allow for code such as: