This is the code I wrote:
int main()
{
int nc;
nc=0;
while(getchar()!=EOF)
{
++nc;
printf("%i\n",nc);
}
return 0;
}
The output lists the number of characters like 1, 2, 3 instead of giving a total count. Removing the curly brackets enclosing the while loop or putting the 'printf' statement outside the loop resulted in no output at all.