getchar() != EOF

前端 未结 1 1228
说谎
说谎 2020-12-03 19:36

I am running the following program from the C Programming Language book:

#include 
main()
{
  int c;
  while((c=getchar()) != EOF)
    putchar         


        
相关标签:
1条回答
  • 2020-12-03 20:28

    When you type ^D ('end-of-transmission') the input buffer is flushed and everything you typed until now is sent to your program (without actually sending ^D character). It is similar to typing newline character, however, in this case the newline character itself is sent too. A program considers its input as closed when it reads zero characters. This happens when you type newline followed by ^D or two consecutive ^D.

    0 讨论(0)
提交回复
热议问题