#include <iostream>
#include <conio.h>
#include <chrono>
#include <thread>
using namespace std;
int main() {
do {
time_t curr_time = time(NULL);
system("CLS");
tm* tm_local = localtime(&curr_time);
cout << "Current time : " << tm_local->tm_hour << ":" << tm_local->tm_min << ":" << tm_local->tm_sec << endl;
cout << "To exit the clock click space" << endl;
this_thread::sleep_for(chrono::seconds(1));
char ch = getch();
if (ch == ' ') {
system("CLS");
goto main;
}
} while (true);
}
I have a problem when I execute the program the time is frozen but when I click space it goes to the main as intended
main problem: the time freezes and does not update every second
I was expecting to update the time every second, I have tried using a while loop.