C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-05-2009, 04:19 PM   #16
Registered User
 
Join Date: Oct 2008
Location: TX
Posts: 1,262
Quote:
Originally Posted by alekbabich View Post
Can you impose a time limit on a command like getchar() ???

I got the program to stop and not loop if the user enters a character rather than a number, but now the program stops and waits for the user to hit a key when they enter a number.
...
One way is to schedule an alarm signal (SIGALRM) to be sent to the process after a number of seconds have elapsed, given as an argument to alarm().
Write a signal handler that sets a flag upon receipt of SIGALRM; check the value of flag in the caller to decide whether to continue or exit the program.
itCbitC is offline   Reply With Quote
Old 07-06-2009, 05:54 AM   #17
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
We're talking platform-specific solutions here, though. Correct me if I'm wrong.
I don't believe there's any standard way of doing it, so the question becomes: for what OS?
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 07-06-2009, 07:08 AM   #18
Registered User
 
Join Date: Jul 2009
Posts: 8
I am running Windows XP, but why is it platform specific?
alekbabich is offline   Reply With Quote
Old 07-06-2009, 07:12 AM   #19
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
There are many things C can do natively, that is with code in its standard library.
However, there is also a lot of things that it cannot do natively, simply because there is no standard pre-existing code that does this.
That is when we must turn to code that exists on operating systems that can do this for us.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C keep a loop going whilst program continues on fortune2k C Programming 6 03-11-2009 08:44 AM
Printing "shapes" based on character lines and number of line inputs matt_570 C++ Programming 11 10-07-2008 06:19 PM
Using While Loop to write a program Cyberman86 C++ Programming 2 09-16-2008 12:52 PM
Unexplained "unhandled exception" ulillillia C Programming 6 04-19-2007 11:19 AM
UNICODE and GET_STATE Registered C++ Programming 1 07-15-2002 03:23 PM


All times are GMT -6. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22