timed user input

This is a discussion on timed user input within the C Programming forums, part of the General Programming Boards category; Hi, I am writing a C program where I have to ask user to input under a certain time. It ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    Arrow timed user input

    Hi,

    I am writing a C program where I have to ask user to input under a certain time. It should ask user for input for 5 counts or so. Whether the user enters anything or not, it should halt getting the input and proceed further with the program.

    I am doing this by taking the help of uscos II multitasking. I have two tasks, one to get the user input and another to keep updating counts.

    I am able to use if and while statements to get user input for certain period of time, but when the time finishes it just terminates the whole program, sometimes it also gives error related to memory. It is expected since I have not implemented anything which will automatically stop getting user input after certain period of time. Is there some specific function to do this?

    Thanks in advance!

  2. #2
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    i have no idea what uscos II multitasking is but

    you need 3 processes 1 for main program 1 for timer 1 for user input if timer goes out end the user input process.

    or you can do it with threads the c program process envokes a process containing 2 threads 1 for timer 1 for user input, when timer thread joins the main thread, force the user thread to terminate.
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by creeping death View Post
    i have no idea what uscos II multitasking
    You probably should have used google before you wasted your breath then; looks like this is for an embedded system.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    so what? the main idea is that 2 "tasks" or "processes" wont be enough...
    Code:
    printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Okay BUT if you had googled (read the OP again) I bet you wouldn't have jumped the gun like that.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  4. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 10:53 AM
  5. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 06:01 AM

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