zoukankan      html  css  js  c++  java
  • _kbhitChecks the console for keyboard input

    来源:MSDN

    _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' 
  • 相关阅读:
    C# 杨辉三角 下
    C# 自动走迷宫 下
    算法练习之1数字填充 下
    动态添加控件并获取其值
    两个ListBox的互动
    VS2005常用快捷键
    GridView内嵌DropDownList操作
    GridView格式化短日期
    获得客户端ID
    Access数据库 Update 语句的怪现象
  • 原文地址:https://www.cnblogs.com/joeblackzqq/p/1880459.html
Copyright © 2011-2022 走看看