Hi folks. I need a way to display a counter in seconds until it reaches a user defined limit. I have tried but unfortunately not having much luck.
#include <cstdlib>
#include <iostream>
#include <ctime> // time header
using namespace std;
int main()
{
cout << "Please enter seconds: ";//prompt for user
int timer; //int for user input
cin >> timer; //user input
timer = clock();
while ( (timer / 1000) < 60) // While the program hasn't been going for 60 second
{
system("cls"); // Clear All of the text
timer = clock(); // Update the timer var
cout << "Seconds since started: " << timer / 1000 << endl; // Print the time since the program started in seconds
}
cout << "The program has been going for a minute" << endl;
system("pause");
return 0;
}
Thanks in advance!