12345678910111213141516171819202122232425
#include <iostream> #include <ctime> void doSomething(); int main() { while(true) { doSomething(); clock_t timer = clock(); while(((clock() - timer) / CLOCKS_PER_SEC) <= 5) { //do nothing } } return 0; } void doSomething() { std::cout << "Did Something!\n"; }