down

Stanislaw L. Olejniczak slores%gables.span at umigw.miami.edu
Sun Dec 11 02:22:45 AEST 1988


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.  A person I much respect for his C
knowledge told me that this would be too complex for a compiler.  I would
appreciate if some other people would express their opinion if the statement is
legal in C.  chcnt is a long int, c is a char.
Many thanks!
----
Stan Olejniczak           Internet:   slores%gables.span at umigw.miami.edu
University of Miami       UUCP:       {uunet!gould}!umbio!solejni
Miami, Florida, USA       Voice:      (305)-547-6005
My opinions cannot possibly represent the views of anyone else!



More information about the Comp.lang.c mailing list