A question of style
barmar at think.com
barmar at think.com
Sat Dec 2 07:03:36 AEST 1989
I hope you're prepared for a flood of followups (I know *I've* gotten them
when I've goofed like this)....
In article <427 at jhereg.Minnetech.MN.ORG> mark at jhereg.minnetech.mn.org (Mark H. Colburn) writes:
>The code above could be written as
> while (c = getchar && c != EOF) {
>Which most programmers would find "more intuitive" than the comma seperated
>one.
Except, of course, that it is *not* equivalent (and I'm ignoring the
missing parentheses after "getchar"). In the comma-separated version the
loop only ends when getchar() returns EOF. Your version terminates the
loop when getchar() returns either 0 (e.g. if the user types Control-@) or
EOF.
Barry Margolin, Thinking Machines Corp.
barmar at think.com
{uunet,harvard}!think!barmar
More information about the Comp.lang.c
mailing list