473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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.

--
Patrick M.
/* EOF */
Nov 15 '05 #1
2 2060
"Patrick M." <mc****@gmail.com> writes:
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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #2
Keith Thompson wrote:
"Patrick M." <mc****@gmail.com> writes:
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.


Excellent! Thanks a lot. From now on I will refer to that website first.
Thanks for the prompt reply, though. I will try to do what is suggested
in there.

--
Patrick M.
/* EOF */
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: voidstar | last post by:
Hi, I have the following problem: I use "getch" to monitor keypresses and the I use "cin" to input a string. When I type in 'y', the 'y' character appears, so I need to hit backspace before...
2
by: Shugong Wang | last post by:
getch() function is not a standard C/C++ function. Thought gcc provieds ncurses.h and a getch() function is realized, I still want to know how to realize a getch() function in standard c or c++.
4
by: lior l | last post by:
Hello, I am looking for a C function that works just like getch() in C++, meaning I want the computer to wait for a one byte input and continue (without pressing on the enter key). I have tryied...
15
by: Profetas | last post by:
Hi, How do I read a char from stdin before the '\n' is pressed? for example I know that I can use getch() to read a single char from the user input, but suppose I wanted to read before the...
4
by: Crow | last post by:
Is there any way to make cin behave like getch()? Specifically, getch() returns immediately after a key is pressed and the cin family of input methods seem to block until a new line is...
9
by: James McLaughlin | last post by:
Hi, Does anyone know if it's possible to write either a getch() (preferably Borland-style) or getche() function in C without it being platform-dependent or otherwise non-standard? If not, can...
6
by: John (Z R) L | last post by:
Hi all, I am very new to programming, and I chose to study the Python language before C++. I am currently using the Wikibooks "Non-Programmer's Tutorial for Python", and am up to the section "Who...
5
by: Sankar | last post by:
Dear all, In my programming snippet compiled in Linux 2.6, I have a getch() , but the program when executed does not wait for my input.. fflush(stdin), fflush(stdout) - All these did not help. ...
16
by: fuzhen | last post by:
If I want to "press any key to continue" in Windows, I can use getch() But the getch() isn't a standard C function So what should I to do in Linux?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.