mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 06:55:36 +08:00
41 lines
877 B
HTML
41 lines
877 B
HTML
<h1>输入输出 - kbhit</h1>
|
||
|
||
|
||
<p>原型:extern int kbhit(void);</p>
|
||
|
||
<p>用法:#include <stdio.h></p>
|
||
|
||
<p>功能:检测按键</p>
|
||
|
||
<p>说明:检测键盘是否有键按下。</p>
|
||
如果有键按下,则返回对应键值;否则返回零。
|
||
kbhit不等待键盘按键。无论有无按键都会立即返回。
|
||
|
||
举例:<pre><code class="language-c">
|
||
|
||
// kbhit.c
|
||
|
||
#include <stdio.h>
|
||
|
||
main()
|
||
{
|
||
int i=0;
|
||
|
||
clrscr();
|
||
|
||
while(!kbhit())
|
||
{
|
||
clrscr();
|
||
printf("%05d",i++);
|
||
}
|
||
|
||
clrscr();
|
||
printf("End.");
|
||
|
||
getchar();
|
||
return 0;
|
||
}
|
||
|
||
</code></pre>相关函数:<font color=gray>getkey,getch</font>,<a href="getchar.html">getchar</a>
|
||
|