In C++11, you can do this with standard library facilities:

#include <chrono> #include <thread>

std::this_thread::sleep_for(std::chrono::milliseconds(x));