Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!labrea!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: down Message-ID: <843@quintus.UUCP> Date: 12 Dec 88 07:41:09 GMT References: Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 22 In article slores%gables.span@umigw.miami.edu (Stanislaw L. Olejniczak) writes: > while ( (c = getchar) != EOF) > chcnt++ += (c == '\n'); No way is this too complex for a compiler. It is just plain illegal. chcnt is a 'long' _variable_ (L-value), but chcnt++ is a 'long' _number_ (R-value). The first time round, chcnt would be 0, then chcnt++ increments chcnt to 1 and evaluates to 0. What would "0 += (c == '\n') mean? Try chcnt++, chcnt += c=='\n'; Better still would be to use a for loop: for (chcnt = 0; (c = getchar()) != EOF; chcnt++) { if (c == '\n') chcnt++; } or for (chcnt = 0; (c = getchar()) != EOF; chcnt += c == '\n' ? 2 : 1) ; (Was that really (c = getchar), or was it (c = getchar())? If the former, that's wrong too.)