MS DOS not pausing while waiting for imput.

This is a discussion on MS DOS not pausing while waiting for imput. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Is there a way to check for imput with out pausing and promting for imput? if i use: cin >> ...

  1. #1
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704

    MS DOS not pausing while waiting for imput.

    Is there a way to check for imput with out pausing and promting for imput? if i use:
    cin >> somecharacter;
    it pauses everything and waits till you give a character. How can i ask for imput and keep my program going.



    thanks.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Cool Like this?

    Code:
    
    int main()
    {
      char Input=0;
      while(Input!=27) //Loop while ESC is not pressed.
      {
        Input=0;
        if(kbhit()) Input=getch(); //Store the pressed key (if a key is pressed)
    
        //Your code
    
      }
    }
    
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    For that code to work, don't forget to #include <conio.h>
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speed test result
    By audinue in forum C Programming
    Replies: 4
    Last Post: 07-07-2008, 05:18 AM
  2. MS DOS Window closes right away!
    By poolshark1691 in forum C++ Programming
    Replies: 5
    Last Post: 05-24-2005, 11:35 AM
  3. Ping
    By ZakkWylde969 in forum Tech Board
    Replies: 5
    Last Post: 09-23-2003, 12:28 PM
  4. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM
  5. Console VS MS DOS window
    By Shadow12345 in forum C++ Programming
    Replies: 5
    Last Post: 07-30-2002, 08:43 AM

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