I am just starting out learning c. Downloaded xcode to my mac and bought The c Programming Language by K&R. I am now at the character counting section and cannot understand the output the program gives me. Program is...
#include <stdio.h>
main()
{
long nc;
nc = 0;
while (getchar() !=EOF)
++nc;
printf("%ld\n", nc);
}
I've learned from these pages that I need to hit ctrl+d twice to send an EOF character to the program and that works ok. However, the answer it gives me is 140,734,799,804,376 (the commas are mine) plus the number of characters in the string. Where does this huge number come from? Why doesn't the program just return 4 for "help" instead of 140734799804380?