|
|

楼主 |
发表于 2026-9-1 21:02:20
|
显示全部楼层
This line reads a keystroke, so the program will pause until you press the Enter key. Sometimes,
depending on how the program functions, there might already be a keystroke waiting. In that
case, you’ll have to use getchar() twice:
getchar();
getchar();
For example, if the last thing the program did was ask you to enter your weight, you would
have typed your weight and then pressed the Enter key to enter the data. The program would
read the weight, the first getchar() would read the Enter key, and the second getchar()
would cause the program to pause until you press Enter again. If this doesn’t make a lot of
sense to you now, it will after you learn more about C input. And we’ll remind you later about
this approach.
给我解释一下 |
|