more questions about efficient C code
Mike Schloss
mhs at enmasse.UUCP
Tue Jul 2 13:26:27 AEST 1985
> I have noticed lately that if I have the following:
>
> foo()
> {
> char c;
>
> if((c = getchar()) != '\n') {
> /* more code here */
> }
> }
>
> and I do not use 'c' any where else lint complains. I get the message
>
> c set but no used in function foo
>
Whats the problem? Lint is telling you that your loop keeps assigning
a value to c and never ever using it. (Is c in WOM :-)
You could get away with something like this:
foo()
{
if (getchar() != '\n') {
/* more code here */
}
}
More information about the Comp.lang.c
mailing list