Why doesn't this work? (3B2 problem)
Wayne Throop
throopw at dg_rtp.UUCP
Sun Mar 30 07:20:06 AEST 1986
> getchar() returns an (int), not a (char). EOF is an (int).
> You're throwing away some of the bits returned by getchar(),
> [...etc,etc...]
> Didn't "lint" catch this?
What, you didn't try it? Why not? :-) Anyhow, feeding this
#include <stdio.h>
void main(){
char c;
while( (c = getchar()) != EOF )
;
}
to SysV lint gives
warning: nonportable character comparison
Myself, I'd druther see lint complain whenever the types fed to an
assignment don't match exactly, rather than allow "implicit casts", but
the fact that quoted characters are of type int kind of spoils this idea
for C, I suspect.
--
Wayne Throop at Data General, RTP, NC
<the-known-world>!mcnc!rti-sel!dg_rtp!throopw
More information about the Comp.lang.c
mailing list