lsbt100
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?
|
||||
Checking the keyboard buffer in Posix C?lsbt100 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? Jason 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... Jason lsbt100 03-28-2003, 07:37 PM Anything in normal C, that looks like C++ to me. Thanks, Lloyd Jason 03-28-2003, 07:50 PM sorry, wasn't thinking.... String n; scanf( "%d", &n ); I think thats right...I haven't used C in a while Jason Phantom 03-28-2003, 08:55 PM Actually, char word[]; and gets(word); :) lsbt100 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: while (1){ updateScreenTime(); //arbitary function checkMP3Status(); if (kbhit()) break; // need the POSIX function that works just //like kbhit() } |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum