问题描述
我是 C 编程语言的初学者,但我了解 QBasic 编程.我在 Qbasic 中制作了很多小程序来解决我的基本任务,最近我正在将这些程序重写为 C .
I am a beginner in C programming language but I have knowledge of programming in QBasic. I make lots of small programs in Qbasic to solve my basic tasks and I am recently rewriting those programs into C .
在重写其中一个程序时,我偶然发现了一个问题,即计算机可以获取输入但不会暂停程序执行.不幸的是,scanf
会导致程序一直等到用户按下任意键并按下 Enter 键,但我需要我的程序运行并且仍然能够获得输入.
While rewriting one of the programs I stumbled upon a problem where the computer would be able to get input but without pausing the program execution. Unfortunately, scanf
would cause the program to wait until the user presses any key and presses enter but I need my program run and still be able to get input.
推荐答案
在 Windows 上,最简单的方法是 kbhit
On windows the easiest way is kbhit
这篇关于C 编程语言中的 INKEY$ 等价物是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!