getchar and putchar

后端 未结 6 1979
耶瑟儿~
耶瑟儿~ 2021-02-06 14:40

My C code:

int c;
c = getchar();

while (c != EOF) {
    putchar(c);
    c = getchar();
}

Why does this program react like this on inputting

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-06 15:00

    Your input is hello and not h e l l o right?

    So the input you give is buffered until you press enter.

提交回复
热议问题