Hi im a c++ beginner and i'm doing a tic tac toe program hollywood squares style only with math questions.
what im trying to do here is im trying to insert a timer such that the player only has 20 seconds to answer each question or he/she loses his/her turn..
but from my code,, im getting the timer needs to finish first before getting the user can answer their question..
how do i do a simulataneous occurence of the start of the timer and the cin?? THanks.
cout << "PLAYER 1: What is the product of " << num1 << " and " << num2 <<"?: ";
int n;
for (n=50; n>0; n--)
{
gotoxy(x1-1,y1-1);
printf ("%d\n",n);
wait (1);
}
cin >> userans;
and as the the wait function above..
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}