1 year ago
#387545
Pedro R.
Detecting user input spent time under C++
I am building a simple game and I need to set some options, including user timeout to end the game. The following piece of code will clarify what I want:
do {
//some code
cin >> ...a char ...;
if( duration > timeoutLimit)
{
cout << "took too long for input ... max imput time reached" << endl;
break;
}
}while(...something...);
This is going to work inside de loop and it breaks, if during the user inputs, that may be several, the maximum time allowed is reached. Using clock()
I only get the time spent on performed calculations and not the time spent with user input which is what I want.
c++
c++11
0 Answers
Your Answer