Confused about getchar() function

后端 未结 6 1685
有刺的猬
有刺的猬 2021-02-07 08:25

I am confused about getchar()\'s role in the following code. I mean I know it\'s helping me see the output window which will only be closed when I press the En

6条回答
  •  执念已碎
    2021-02-07 08:45

    The getchar() function will simply wait until it receives a character, holding the program up until it does.

    A character is sent when you hit the enter key; under a Windows OS, it will send a carriage return (CR) and a line-feed (LF).

    See this CodingHorror post for a nicely put explanation.

    (...the explanation of the CR+LF part, not the getchar() blocking part)

提交回复
热议问题