View Full Version : Checking the keyboard buffer in Posix C?
03-28-2003, 06:57 PM
I'm programming in C on a Linux box and wondered if there was a way to check if the keyboard had been pressed, like kbhit but the Posix function?
03-28-2003, 07:33 PM
you could try this...I don't think its what you want but its really simple...
if ((cin>>X) > "")
that should work if X is declared as a string...
03-28-2003, 07:37 PM
Anything in normal C, that looks like C++ to me.
03-28-2003, 07:50 PM
sorry, wasn't thinking....
scanf( "%d", &n );
I think thats right...I haven't used C in a while
03-28-2003, 08:55 PM
03-29-2003, 11:49 AM
Surely both of those methods block, i.e wait until the user has actually pressed the keyboard before the program can move on.
What I want is a function like kbhit() (that isn't in POSIX C though), that I can poll regularly, e.g:
updateScreenTime(); //arbitary function
if (kbhit()) break; // need the POSIX function that works just
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.