santosh said:
What about character values that are outside of the common set of values
for unsigned char and int? How can they be returned?
getc() is supposed to read one character at a time as an unsigned char.
When UCHAR_MAX > INT_MAX (which is guaranteed when sizeof(int)==1, and
possible though unlikely when sizeof(int) > 1), the conversion from
unsigned char to int has either an implementation-defined result or
raises an implementation-defined signal. If such an implementation were
to raise a signal from that conversion, I would consider it broken, but
not necessarily non-conforming. Similarly, if such implementation were
to define the conversion from unsigned char to int in such a way that it
was not a perfect inverse of the conversion from int to unsigned char, I
would also consider it broken, though not necessarily non-conforming.
On an implementation where sizeof(int)==1 and unsigned char=>int is a
perfect inverse for int=>unsigned char, I don't see any unavoidable
problem. Of course, there, is a great deal of code which does not avoid
the possible problems.