getchar() and stdin

后端 未结 3 1830
野性不改
野性不改 2021-02-09 04:27

A related question is here, but my question is different.

But, I\'d like to know more about the internals of getchar() and stdin. I know that getchar() just ultimately c

3条回答
  •  情歌与酒
    2021-02-09 04:47

    getchar()'s input is line-buffered, and the input-buffer is limited, usually it's 4 kB. What you see at first is the echo of each character you're typing. When your press ENTER, then getchar() starts returning characters up to the LF (which is converted to CR-LF). When you keep on pressing keys without LF for some time, it stops echoing after 4096 characters, you have to press ENTER to continue.

提交回复
热议问题