CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    25

    [RESOLVED] How to have time out for user input?

    Hi,
    when using std::cin >> x; for getting a variable from user
    the program is halted until the user inputs something. but
    i want to have a time out (e.g. 10 seconds) which after
    that the program continues with a default option.
    how cant I get such a functionality?

    Thanks in advance

  2. #2
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    Re: How to have time out for user input?

    There is no way to do that with standard c++ functionality.
    You will have to use OS features.
    Kurt

  3. #3
    Join Date
    Aug 2009
    Posts
    25

    Re: How to have time out for user input?

    Then what should i do for linux & windows cases?

  4. #4
    Join Date
    Aug 2009
    Posts
    25

    Re: How to have time out for user input?

    could anyone tell me what function should I use for unix/linux?

  5. #5
    Join Date
    Aug 2009
    Posts
    25

    Re: How to have time out for user input?

    really need that, any tip is greatly appreciated
    thanks!

  6. #6
    Join Date
    Aug 2009
    Posts
    25

    Re: How to have time out for user input?

    I have found a solution to it in the below page under
    section "Implementing Timers Using Signals"
    http://users.evtek.fi/~tk/rtp/signal....html#catching
    we can use alarm() function call in unix
    Last edited by ar115; May 1st, 2010 at 07:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured