Adding a loop

This is my code for a digital clock but it only displays the time once when you start the program. Can someone please help me add a loop so it will keep on refreshing until I end the program?

#include <iostream>
#include <ctime>
#include <iomanip>
using namespace std;

char dateStr [9];
char timeStr [9];
char almtimestr[9];

int main()
{
_strtime_s( timeStr);
_strtime_s( almtimestr);

int consoleWidth=70;
cout<<setw(consoleWidth / 2)<<" "<<"The current time is: "<<timeStr<<endl;
cout<<setw(consoleWidth / 2)<<" "<<endl;
cin >> almtimestr;
}
1
2
3
4
5
6
7
8
9
10
//Store the current time in a variable
//display the initial time
while(true) //runs forever because true is always true
{
   if(/* current time is different from the time stored in the variable */)
   {
      //store the new time in the time variable
      //display the time variable
   }
}
Last edited on
Topic archived. No new replies allowed.