View Single Post
Old 02-12-2003, 11:50 AM   #3 (permalink)
Gorbash9k
Registered User
 
Join Date: Feb 2003
Location: Virginia
Posts: 2
Gorbash9k is on a distinguished road
Send a message via AIM to Gorbash9k
I should have told my problem more indepth, I needed a way for the game to keep running while the user is inputting his command. I finally though of a way though, I'm going to set a timer of some small amount, where if the user doesnt input when the timer runs out, the computer will just put in a NULL response and continue on. My problem now is how to set a timer.

Anyways this is the program that my friend sent me.

/////////////////////////////////////////////////////////////////////////////////

#include <conio.h>

#include <iostream>
using std::cout;
using std::endl;

int main()
{
char tmp;

system("cls");

cout << "Hit a key, please ('q' to quit)." << endl;

do
{
while(!_kbhit());
tmp = _getch();
cout << tmp;
} while (tmp != 'q');

cout << endl << endl;

system("pause");
return 0;
}
/////////////////////////////////////////////////////////////////////////////////
Gorbash9k is offline   Reply With Quote