Why can't I find the value of EOF in C?

前端 未结 6 751
梦毁少年i
梦毁少年i 2020-12-30 13:48

I\'m reading the book \"The C Programming Language\" and there is an exercise that asked to verify that the expression getchar() != EOF is returning 1 or 0. Now

6条回答
  •  一生所求
    2020-12-30 14:30

    Because if c is EOF, the while loop terminates (or won't even start, if it is already EOF on the first character typed). The condition for running another iteration of the loop is that c is NOT EOF.

提交回复
热议问题