Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!haven!purdue!decwrl!hplabs!hp-sdd!ncr-sd!ncrcae!secola!broadway!furlani From: furlani@broadway.UUCP (John L. Furlani) Newsgroups: comp.lang.c Subject: Re: Simple C Question (was: down) Message-ID: <192@broadway.UUCP> Date: 11 Dec 88 13:18:00 GMT References: Organization: University of South Carolina, College of Engineering 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 This snippit of code should do it. It will count the newlines, but it won't count the returns. while ((c = getc(infile)) != EOF) if (c == '\r') chcnt++; As for 'chcnt++ += (c == '\n')', you can't assign what is being incremented to anything. This is different of course from '*count++ = 45' where the pointer is being incremented and the info contained in the pointer is being assigned. Flame? Who us? ____________ Disclaimer: "It's Mine! Mine! All Mine!!" John L. Furlani The University of South Carolina, Columbia SC (...!uunet!ncrlnk!ncrcae!broadway!furlani)