<C new> - question about an example in C: The Programming Language
I'm a total newb to C. I bought C: The Programming Language to start learning, but I have a question about a couple examples, one to count characters, the other to count lines. They're not printing anything, and I'm not sure why. I've double and triple checked everything, making sure I have exactly what's in the book, but to no avail. I'm using Code Blocks 8.02 and Vista.
The second example, the second version, doesn't work either.
/* count characters in input; 1st version */
nc = 0;
while (getchar() != EOF)
The third is the line counting one
/* count characters in input; 2nd version */
for (nc = 0; getchar() != EOF; ++nc)
Any help is appreciated, of course. Thanks.
/* count lines in input */
int c, n1;
n1 = 0;
while ((c = getchar()) != EOF)
if (c == '\n')