Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!hal!nic.MR.NET!tank!mimsy!haven!uvaarpa!mcnc!rti!sunpix!matthew From: matthew@sunpix.UUCP ( Sun NCAA) Newsgroups: comp.lang.c Subject: Re: down Message-ID: <349@greens.UUCP> Date: 11 Dec 88 21:58:26 GMT References: Organization: Sun Microsystems, Research Triangle Park, NC Lines: 28 In article , slores%gables.span@umigw.miami.edu (Stanislaw L. Olejniczak) writes: > PLEASE don't flame for posting too simple a question. I think the following > SHOULD work, but will not even compile: > while ( (c = getchar) != EOF) > chcnt++ += (c == '\n'); > The purpose is to count characters in a file. Each time a newline is > encountered an additional character should be counted: when the file is > transferred, a newline is CR-LF combination. I'm not sure about the validity of the construct 'chcnt++ += (c == '\n');', but I'd write your program scrap as: while ( (c = getchar) != EOF) { if (c == '\n') chcnt++; chcnt++; } (Before closing, there is one logic flaw in your scrap of code. '(c == '\n')' does not have to evaluate to an integer 1. It must only be a non-zero value if true.) -- Matthew Lee Stier (919) 469-8300| Sun Microsystems --- RTP, NC 27560| "Wisconsin Escapee" uucp: {sun, rti}!sunpix!matthew |