Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!genrad!panda!talcott!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: more questions about efficient C code (really lint) Message-ID: <617@umcp-cs.UUCP> Date: Mon, 1-Jul-85 21:53:40 EDT Article-I.D.: umcp-cs.617 Posted: Mon Jul 1 21:53:40 1985 Date-Received: Fri, 5-Jul-85 04:45:49 EDT References: <3136@drutx.UUCP> <3928@alice.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 23 There is actually a difference between char c; while ((c = getchar()) != '\n') and while (getchar() != '\n') The latter expression compares the return value of getchar() (an int) with '\n' (another int). The former compares the value of the assignment "c = getchar()" (a char) with an int. Lint is arguably correct in complaining, as "c" itself is not actually used in the comparison, but it does have an effect. By the way, the former section of code is technically incorrect: getchar returns an int, since EOF is supposed to be something that is not valid as a char. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland