In addition to Jon Lin, answer about EOF, I'm not sure if the code you wrote is what you intended. If you want to see the value returned from getchar in variable d , you need to change the while statement to:
while((d=getchar())!=EOF) {
This is due to the fact that the inequality operator has a higher priority than assignment. So in your code, d will always be either 0 or 1 .
jxh
source share