Simple <Time.h> program takes large amount CPU
问题 I was trying to familiarize myself with the C time.h library by writing something simple in VS. The following code simply prints the value of x added to itself every two seconds: int main() { time_t start = time(NULL); time_t clock = time(NULL); time_t clockTemp = time(NULL); //temporary clock int x = 1; //program will continue for a minute (60 sec) while (clock <= start + 58) { clockTemp = time(NULL); if (clockTemp >= clock + 2) { //if 2 seconds has passed clock = clockTemp; x = ADD(x);