This example is from "The C Programming Language" by Dennis Ritchie and Brian Kernighan. It is supposed to take in characters given by user input, and then when an EOF is stated (using my Mac, it is ctrl-D), it ends the program and shows the amount of characters inputted. Instead it doubles the actual value of the amount of characters. Am I missing something? Thank you.
#include <stdio.h>
main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%1d\n", nc);
}