down
Doug Gwyn
gwyn at smoke.BRL.MIL
Sun Dec 11 16:07:21 AEST 1988
In article <gables.352 at umigw.miami.edu> slores%gables.span at umigw.miami.edu (Stanislaw L. Olejniczak) writes:
> while ( (c = getchar) != EOF)
> chcnt++ += (c == '\n');
The main problem is that getchar is a function-like macro, requiring
usage of a parenthesized argument list (containing no arguments), i.e.
getchar()
The next problem is that the result of chcnt++ is not a modifiable
lvalue, so you cannot assign to it. Split the statement into two
parts.
The final problem is that you say c is a char. In that case it can
never compare equal to EOF on many systems. getchar() returns an int,
not a char.
>... told me this would be too complex for a compiler.
Well, if it weren't for the other problems, I would say that any C
compiler that cannot handle expressions that complex is not worth
using. Seriously!
More information about the Comp.lang.c
mailing list