#include <sys/select.h>
#include <termios.h>
#include <sys/ioctl.h>
 int _kbhit()
 {
        static const int STDIN = 0;
        static bool initialized = false; if (! initialized)
        {
            // Use termios to turn off line buffering
            termios term;
            tcgetattr(STDIN, &term);
            term.c_lflag &= ~ICANON;
            tcsetattr(STDIN, TCSANOW, &term);
            setbuf(stdin, NULL);
            initialized = true;
        } int bytesWaiting;
        ioctl(STDIN, FIONREAD, &bytesWaiting);
        return bytesWaiting;
        
  }

至于干什么用,你发现了它就表示你则知道它是做什么用的。

posted on 2013-09-28 16:41  瓦楞球  阅读(687)  评论(0编辑  收藏  举报