Thread: Getting user input without pausing

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    18

    Getting user input without pausing

    Is there a simple way to allow user input without having the program "wait" for it?

    For example, I want to write a function that counts down from 100 to 0. The only way to stop it would be if the user enters a certain phrase. I want to make sure that the count down is absolutely uninterrupted unless the exact phrase is entered.

    So, how would I have a variable ready to be changed by the user, and also a function running at "the same time" so to speak?

    thanks!

    Here's some mock code for what I can come up with so far.

    Code:
    for (int i = 100; i > 0; i--)
    { 
      cin >> password;
      if (password != 'stop')
    
        // pause for 1 second
        cout << i << "..." << endl;
    }
    So that's the basic idea of what I want, except in that example, the function will pause every time and "wait" for input right?
    Last edited by Xanderbeard; 07-10-2010 at 01:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. handling user input
    By rodrigorules in forum C++ Programming
    Replies: 4
    Last Post: 11-12-2009, 06:21 AM
  2. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  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. vectors and user input
    By Chaplin27 in forum C++ Programming
    Replies: 6
    Last Post: 01-17-2005, 10:23 AM
  5. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 10:53 AM