A question of style
Geoffrey Rogers
grogers at sushi.uucp
Fri Dec 1 11:51:53 AEST 1989
In article <1989Nov30.001947.14883 at aqdata.uucp> sullivan at aqdata.uucp (Michael T. Sullivan) writes:
>From article <547 at mars.Morgan.COM>, by amull at Morgan.COM (Andrew P. Mullhaupt):
>while (c = getchar(), c != EOF)
>{
> ...
>}
>
>I posted this instead of mailing it to see what, if any, reaction it got.
>I'm always interested in coding style.
In this case I would write the above as:
while ((c = getchar()) != EOF)
{
...
}
IHMO this is much clearer then the above. In general the only places
I have found to use the comma operator is either in for-statements,
macros and maybe within expressions of ? : expression.
Geoffrey C. Rogers "Whose brain did you get?"
grogers at convex.com "Abbie Normal!"
{sun,uunet,uiucdcs}!convex!grogers
More information about the Comp.lang.c
mailing list