Different method, same problem.
I lose 2-seconds every 10-minutes.
But, with this method, it catches it to then re-sync.
Code:
#include <windows.h>
#include <time.h>
#include <iostream>// cout
using namespace std;
int main(){
SYSTEMTIME st;
time_t tSecs;
int Secs,iStall=1;
bool looping=true;
while(looping){
GetLocalTime(&st); Secs=60000-(((int)st.wSecond*1000)+(int)st.wMilliseconds);
Sleep(Secs);
tSecs=time(0); char timestamp[20]; struct tm pSecs;
localtime_s(&pSecs,&tSecs); strftime(timestamp, 20, "%X", &pSecs);
cout << Secs <<"\t= "<< timestamp <<"\n";
Sleep(753*(iStall%5)); iStall++;
}
return 0;
}