Friends,
I am doing K&R book problem 1.6 in exercise
So C should get 0 or 1 depending on input is any character or EOF.Code:#include <stdio.h> main() { int c; while(c=(getchar() != EOF)) { printf("%d\n",c); } printf("on pressing ^d output is %d\n",c); }
On executing this program in GCC, I get the following output:
> ./a.out
d
1
1
2
1
1
On pressing ctrl d, I get
0
But I am not getting why 1 is getting printed Twice instead of only ONE time?
Any answers?
Thanks
Saurav