Thread: not able to work for alarm clock

  1. #1
    Registered User
    Join Date
    Oct 2009

    not able to work for alarm clock

    i have want to simple program which will do the following->
    1. Display enter the name message
    2. Accept input for 5 secs
    3. if user is successful to write message in 5 secs then he wins
    4. else looses.

    I want to do it with the use of alarm() system call on unix.

    char *name;
    void wakeup()
    int main()
    printf("Enter the name :->");
    return 0;

    Problems with the code:
    1. It is not following the flow, seems that pause() has more priority. The message ""Enter the name :->", is displayed with delay.
    2. whenever control goes to wakeup, scanf blocks the control for infinite period. I mean unless I press ENTER, control wont do anything. So whole idea of terminating the input process after 5 secs becomes useless

    how to do it???

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    There is no standard kbdhit function. Most input functions are line buffered. That means you have to hit enter. It will wait until you do.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Error in Clock program
    By SVXX in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2009, 12:12 AM
  2. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  3. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  4. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  5. ANN: The Fourth Contest: Alarm Clock, sign up here
    By ygfperson in forum A Brief History of
    Replies: 59
    Last Post: 08-10-2002, 12:24 AM