非阻塞键盘检测getchar()

#include <stdio.h>
#include <conio.h>
#include <Windows.h>
int main()
{
    char c;
    while (true)
    {
        if (_kbhit())//判断是否有键盘按下
        {
            c = getchar();
            printf("%c\n", c);
            Sleep(1000);
        }
        printf("_____");
        Sleep(10);
    }
    return 0;
}

 

posted @ 2016-01-06 17:13  qijinbiao1  阅读(1075)  评论(0编辑  收藏  举报