1 Discussion / Question Topic
Remove Filter [url=http://cc.byexamples.com/2007/04/08/non-blocking-user-input-in-loop-without-ncurses/]code from this blog[/url] [code]int kbhit() { struct timeval tv; fd_set fds; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0 select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); return FD_ISSET(STDIN_FILENO, &fds); }[/code] [code]void nonblock(int state) { struct termios ttystate; //get the terminal state tcgetattr(STDIN_FILENO, &ttystate); if (state==NB_ENABLE) { //turn … |
The End.