I'm needing minutes to always be 00 seconds. But after running my code for a few minutes, it jumps to 58 seconds. I cannot see any reason why. Anyone have any ideas? Thanks.
Code:
#include <windows.h>
#include <ctime>
#include <iostream>// cout
using namespace std;
int main(){
string dataStr;
clock_t cSecs; time_t tSecs;
int Secs,elapsedTime=0,iStall=1;
Secs=(60-((int)time(0)%60))*1000;// first 00
bool looping=true;
while(looping){
Sleep(Secs); cSecs=clock(); tSecs=time(0);
char timestamp[20]; struct tm pSecs;
localtime_s(&pSecs,&tSecs);
strftime(timestamp, 20, "%X", &pSecs);
cout << Secs <<" + "<< elapsedTime <<"\t= "<< timestamp <<"\n";
Sleep(753*(iStall%5)); iStall++;
elapsedTime=(clock()-cSecs)*1000/CLOCKS_PER_SEC;
Secs=(60000-elapsedTime);
}
return 0;
}