Previously Gerhard Tonn wrote: > >>The following code fragment will ignore the end-of-file when char is > >>implemented using unsigned char, due to internal conversions between data > >>types: > >> > >> char c; > >> while ((c = getchar()) != EOF) > >> process character in c
> In other contexts the right solution is to make the type of the variable > 'signed char'. No, the right solution here is make c of type `int'. getchar() does not return a char for a very obvious reason: if it did one would not be able to distinguish between a valid character read from the keyboard and an error condition. Wichert. -- _________________________________________________________________ /[EMAIL PROTECTED] This space intentionally left occupied \ | [EMAIL PROTECTED] http://www.liacs.nl/~wichert/ | | 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0 2805 3CB8 9250 2FA3 BC2D |