回覆列表
  • 1 # 小吶不帥但很實在

    函式簡介

    編輯

    函式名:kbhit()(VC++6.0下為_kbhit())

    功 能及返回值: 檢查當前是否有鍵盤輸入,若有則返回一個非0值,否則返回0

    用 法:int kbhit(void);

    包含標頭檔案: include <conio.h>

    2程式示例

    編輯

    C語言

    1

    2

    3

    4

    5

    6

    7

    8

    9

    #include<stdio.h>

    #include<conio.h>

    intmain(

    void

    )

    {

    printf

    (

    "Pressanykeytocontinue:"

    );

    while

    (!kbhit())

    /*donothing*/

    ;

    printf

    (

    "\r\nAkeywaspressed...\r\n"

    );

    return0;

    }

    下面的程式碼,如果沒有鍵盤輸入程式一直輸出Hello World,直到使用者按Esc結束

    #include <conio.h>

    #include <stdlib.h>

    int main( void )

    {

    char ch;

    while( !kbhit() )

    {

    cprintf("Hello World\n");

    if( kbhit() )

    {

    ch = getch();

    if( 27 == ch )

    break;

    }

    }

    cprintf("End!\n

  • 中秋節和大豐收的關聯?
  • 一些親子節目裡,寶寶們的英語都很好,這是現場有人指導嗎?