Exiting a getch() if no input received...

P

Patrick M.

Hello everyone. I'm creating a simple bingo game. After the board is
drawn on the screen, I try to get input from the user. If they enter an
'm', the application marks the random letter and number on the bingo
board. If they type 'b', the application checks for bingo... you get the
point.

Now, if no input is received within x seconds, I would like to go on
with the rest of my application (drawing another letter and number,
printing the board again, asking user what to do). However, I'm not sure
how to do this. Someone suggested I use getch() and call SIGALRM or
SIGINT. But how would I get out of the getch() then? I'm new to C and
confused on what to do. Any suggestions on what to do, that would be
greatly appreciated.
 
K

Keith Thompson

Patrick M. said:
Hello everyone. I'm creating a simple bingo game. After the board is
drawn on the screen, I try to get input from the user. If they enter
an 'm', the application marks the random letter and number on the
bingo board. If they type 'b', the application checks for bingo... you
get the point.

Now, if no input is received within x seconds, I would like to go on
with the rest of my application (drawing another letter and number,
printing the board again, asking user what to do). However, I'm not
sure how to do this. Someone suggested I use getch() and call SIGALRM
or SIGINT. But how would I get out of the getch() then? I'm new to C
and confused on what to do. Any suggestions on what to do, that would
be greatly appreciated.

The C FAQ is at <http://www.eskimo.com/~scs/C-faq/faq.html>.
You've asked question 19.2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top