Is there a better way to do this than with the system up time? (Is there an actual command in C++ to perform an action every x seconds?)Code:while(true) { if (system uptime % 5 == 0) { //do stuff } }
This is a discussion on Possible to run while Loop Every 5 Seconds? within the C++ Programming forums, part of the General Programming Boards category; Code: while(true) { if (system uptime % 5 == 0) { //do stuff } } Is there a better way ...
Is there a better way to do this than with the system up time? (Is there an actual command in C++ to perform an action every x seconds?)Code:while(true) { if (system uptime % 5 == 0) { //do stuff } }
Most OS's have a sleep command (with various capitalizations) that allow your program to cede x amount of time to other processes and resume afterwards.