down

david wald wald-david at CS.YALE.EDU
Tue Dec 13 07:33:29 AEST 1988


In article <843 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
>
>       for (chcnt = 0; (c = getchar()) != EOF; chcnt += c == '\n' ? 2 : 1)
>           ;

Urgh.  Yes, it's not *too* unreadable, yes it's correct, but if you're
going to do it like that, why bother eliminating the while loop:

while ((c = getchar()) != EOF)
    chcnt += (c == '\n' ? 2 : 1);


And, precedence rules be damned, I'd put in the parentheses.

============================================================================
David Wald                                              wald-david at yale.UUCP
						       waldave at yalevm.bitnet
============================================================================



More information about the Comp.lang.c mailing list