Code:
#include <stdio.h>
int main()
{
long cn=1;
char ch;
while((ch=getchar())!=EOF)
{
printf("%ld\t%c\n",cn++,ch);
}
}
When I input word "secret" and hit enter it shows count up to 7 and not 6,why?
Because the "enter" character is read as well. This is in fact a "newline", ASCII code 10 (or hex 0A).