more questions about efficient C code

Andrew Koenig ark at alice.UUCP
Sat Jun 29 12:28:37 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

Ummm... isn't lint right?  Why couldn't you just write:

	if (getchar() != '\n') { ...



More information about the Comp.lang.c mailing list