hi, im very new to C programming so this will probably look obvious to you. I Searched for this problem but couldnt find the same one although i did find one about getchar() but it looked more complicated than the bit of code im learning so i dont think it wouldve helped.
Anyway ive just got the 2 books i ordered from Amazon called "The C Programming Language second Edition" and "The C Answer Book Second Edition" which provides solutions for the exercises provided in the first one i mentioned.

On page 18 this is the code, yet it repeats getchar() every time the loop starts again, Therefore the printed code is never reached. Does anybody know how to fix this? It says all the bits of code were compiled and tested but why did they miss this bit? Its meant to count the characters on input and output the number of characters used. I have checked for mistypes at least twenty times over, this is the code taken from the source:

Code:
#include <stdio.h>

main()
{
	long nc;

    nc = 0;
    while (getchar() != EOF)
          ++nc;
    printf("%1d\n", nc);
}
ive also tried it like this:

Code:
#include <stdio.h>

main()
{
	long nc;

    nc = 0;
    while (getchar() != EOF)
{
          ++nc;
} 
   printf("%1d\n", nc);
}
i have also tried the for loop version and that, as expected had no effect either.

i also once tried changing little bits like this at any stupid attempt to fix it even if i expect it not to work:
Code:
long nc, c;

while ((c = getchar()) != EOF)
Before on an internet tutorial i was learning the input technique scanf, but now im also learning the way this book uses so i can continue with this book understanding everything.

help is greatly appreciated, thanku.

NOTE: I am very new to C so plz try not to use complicated C terms that i would not understand, thnx.