我有一个问题希望能得到大家的帮助!在我的程序中:
do
{……
}while((kbhit())==0);
我想知道“kbhit()”是什么意思?它不是子函数。希望能有哪位高手能给我帮助!谢谢!
----------------解决方案--------------------------------------------------------
我估计是库函数吧,我也没有用过这个函数!
----------------解决方案--------------------------------------------------------
我有一个问题希望能得到大家的帮助!在我的程序中:
do
{……
}while((kbhit())==0);
我想知道“kbhit()”是什么意思?它不是子函数。希望能有哪位高手能给我帮助!谢谢!
原型:extern int kbhit(void); 用法:#include <stdio.h> 功能:检测按键 说明:检测键盘是否有键按下。 如果有键按下,则返回对应键值;否则返回零。 kbhit不等待键盘按键。无论有无按键都会立即返回。
也是网上找到的,我也没用过。
[此贴子已经被作者于2004-05-18 22:05:20编辑过]
----------------解决方案--------------------------------------------------------
谢谢啊!
----------------解决方案--------------------------------------------------------
_kbhit
Checks the console for keyboard input.
int _kbhit( void );
Routine | Required Header | Compatibility |
_kbhit | <conio.h> | Win 95, Win NT |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB | Single thread static library, retail version |
LIBCMT.LIB | Multithread static library, retail version |
MSVCRT.LIB | Import library for MSVCRT.DLL, retail version |
Return Value
_kbhit returns a nonzero value if a key has been pressed. Otherwise, it returns 0.
Remarks
The _kbhit function checks the console for a recent keystroke. If the function returns a nonzero value, a keystroke is waiting in the buffer. The program can then call _getch or _getche to get the keystroke.
Example
/* KBHIT.C: This program loops until the user * presses a key. If _kbhit returns nonzero, a * keystroke is waiting in the buffer. The program * can call _getch or _getche to get the keystroke. */#include <conio.h>#include <stdio.h>void main( void ){ /* Display message until key is pressed. */ while( !_kbhit() ) _cputs( "Hit me!! " ); /* Use _getch to throw key away. */ printf( "\nKey struck was '%c'\n", _getch() ); _getch();}
Output
Hit me!! Hit me!! Hit me!! Hit me!! Hit me!! Hit me!! Hit me!!Key struck was 'q'
----------------解决方案--------------------------------------------------------
原型:extern int kbhit(void);
用法:#include <stdio.h>
功能:检测按键
说明:检测键盘是否有键按下。
如果有键按下,则返回对应键值;否则返回零。
kbhit不等待键盘按键。无论有无按键都会立即返回。
有谁懂得这方面高手,请介绍一下。
----------------解决方案--------------------------------------------------------