c语言kbhit函数在哪里,kbhit()函数
滿意答案
路見(jiàn)不平badao
推薦于 2017.09.14
采納率:52%????等級(jí):6
已幫助:908人
摘自MSDN:
--------------------------------------------------------------------------------
kbhit() Does Not Take Character out of Buffer
Article Last Modified on 03-26-2002
The information in this article applies to:
The C Run-Time (CRT)
Microsoft C for MS-DOS
Microsoft C for OS/2
Microsoft C/C++ for MS-DOS
Microsoft Visual C++ for Windows, 16-bit edition 1.0, 1.5
Microsoft Visual C++, 32-bit Editions 1.0, 2.0, 4.0, 5.0, 6.0
Microsoft Visual C++ .NET (2002)
--------------------------------------------------------------------------------
NOTE: Microsoft Visual C++ NET (2002) supported both the managed code model that is provided by the .NET Framework and the unmanaged native Windows code model. The information in this article applies to unmanaged Visual C++ code only.
Summary
When an application tests the value returned by the kbhit() function, the application must explicitly remove the character from the keyboard buffer after entering the keystroke. Otherwise, kbhit() continues to return TRUE.
The following code example demonstrates the situation:
Sample Code
/*
* Compiler options needed: None
*/
#include
void main(void)
{
while (!kbhit())
; // Waits for keystroke
while (kbhit())
getch(); // Empties buffer
while (!kbhit())
; // Waits for keystroke
}
kbhit()不會(huì)清空緩沖區(qū)內(nèi)容,一旦有鍵盤(pán)事件,必須使用getch()清空緩存,至于為什么cin.sync();會(huì)不能清空緩存我也不太清楚,可能與編譯器有關(guān)
20分享舉報(bào)
總結(jié)
以上是生活随笔為你收集整理的c语言kbhit函数在哪里,kbhit()函数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 淘宝/天猫获取sku详情API接口
- 下一篇: 不忘初心,不负韶华,17款迈巴赫S400