How come this little program returns twice as much as the expected result ?
int counter=0;
while(getchar()!=EOF)++counter;
printf("%d\n",counter);
The goal of this program is to print the number of input characters it gets from the keyboard until EOF signal is received ( I'm using unix so ctr+D). However this is the result on my terminal after I start the program, input inside it a 'c' character from the keyboard and then give it the ctr+D signal :
c
2D
As you see the counter is unexpectedly 2. Moreover what that D stands for ?