more questions about efficient C code

CovartDL zarth at drutx.UUCP
Sat Jun 29 04:14:59 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

I tried reverseing the test as below thinking c would have to appear on the
right side of at least one test but, I get the same error.

		foo()
		  {
		   char c;

		   if('\n' != (c = getchar())) {
		      /* more code here */
		      }
		   }

Is it simply the use of the compound statement structure that causes this??
Thanks in advance for the solution.


				- Zarth Arn



More information about the Comp.lang.c mailing list