Link to home
Start Free TrialLog in
Avatar of wzou
wzou

asked on

getchar() problem

HI, I'm doing a unix programming. However, i get problem when I try to read some input from keyboard. I use "getchar()" to do it, however, the programming is justing waiting there until somebody key in something.  Is there a way to periodly check if there is any key-input in the input-buffer. If there is, then read the key. If not, continue to wait.  I have do this in DOS. However, I don't know how to do it in UNIX.  
ASKER CERTIFIED SOLUTION
Avatar of rbr
rbr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
#include <time.h>
int select(size_t nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout );

#include <curses.h>
halfdelay(1)

#include <fcntl.h>
fcntl(0, F_SETFL, O_NDELAY);

#include <termio.h>
termio.c_cc[VMIN] = 0;
termio.c_cc[VTIME] = 0;
Avatar of wzou
wzou

ASKER

Hi rbr,

Thanks for help. I will appreciate if you could send me the demo . My Email address is wzou@comp.uark.edu.

Best regards!!