I want to get the local time in real time.The code and result is as follow, it showed strange;
int main() {
while (true) {
char sentdata[64] = { 0 };
GetLocalTime(&sys);
sprintf(sentdata, "A,%02d:%02d:%02d.%03d,B\n", sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds);
cout << sentdata << endl;
}
return 0;
}
I tried same code on other PC, the result shown is as following, it can show every millisecond.
Why the tmie is same in some loop? I think the time should be different every loop.