I'm new here , asking questions at least. Always have been able to find good answers here. Trying to get back into programming and relearning C but ran into weird issue.
#include <stdio.h>
main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld \n", nc);
}
When I run it, after I type in any amount of characters and hit enter, it does not print the value of nc. After hitting enter, I can start typing again and well, same story. Really can't see what could be wrong. The only way it works is if I place both ++nc and the printf within brackets. But then when I hit enter, it gives the value 1-to-nc, which is not what I want. I just want nc. Needless to say the type is not the issue either. Thanks in advance