#include #include #include #include int kbhit(void) { fd_set readfds; struct timeval timeout; FD_ZERO(&readfds); FD_SET(0, &readfds); timeout.tv_sec = 0; timeout.tv_usec = 0.5; select(1, &readfds, NULL, NULL, &timeout); if(FD_ISSET(0, &readfds)){ return (!0); } else{ return 0; } }