Good day to everyone. I have this trouble of stopping the timer at a specific time, say I have to stop the timer at 1:30. When I try to run it, it doesn't stop. Please help. Here's my C++ code.
#include <iostream>
#include <time.h>
using namespace std;
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main ()
{
int counter = 0;
int seconds = 0;
int minutes = 0;
for (seconds = 0; seconds < 90; seconds++)
{
if(seconds == 90)
{
cout<<"Time's up!";
}
else
{
if(seconds >= 60)
{
minutes++;
seconds = 00;
cout<< minutes << ":0" << seconds << "\r";
wait(1);
}
else if(seconds < 10)
{
cout<< minutes << ":0" << seconds << "\r";
wait(1);
}
else
{
cout<< minutes << ":" << seconds << "\r";
wait(1);
}
}
}
return 0;
}