Hey guys. Just started learning to code, and loving it so far. However, I have hit a snag with the often recommended C Programming Language by Kernighan and Ritchie, so I thought I would ask here.
In section 1.5.3, he gives a program for counting characters,
which is supposed to count the characters and then display it, but the program never displays the number of characters when I compile it in codeblock 10.05. Moreover, I can get it to count it out if I put the printf inside the loop, but I always gets one more number than the actual number of characters I type in. I have the same problem with
nc = 0;
while (getchar() != EOF)
so I was just hoping someone could help with this. Thanks a lot.
for(nc = 0; getchar() != EOF; ++nc)