First of all as the title suggest I am a newb. I pretty much just started to try and teach myself C, and I would like you to help me if possible.

I am trying to create a small program that counts characters. I am following along in a book and I entered the code exactly as it says, but it doesn't work like it should (it does compile though). I'll post the code below.

Code:
#define EOF -1

main ()
{
	long nc;
	
	nc = 0;
	while (getchar() != EOF)
		++nc;
	printf("%1d\n", nc);
}
Like I said it compiles fine and that is what the book says works. I think the problem is that its getting stuck in the while statement and thus will never actually get to the printf function. I tried myself before posting to try to arrange it in a way that would work, but couldn't seem to figure it out. Like I said I'm a newb to C (along with programming in general) so any help is greatly appreciated.