As you may know, there are multiple ways to create a sleep\delay function in C++.
These may appeal more or less to you depending on system and libraries available.
The following short function uses functionality of time.h header, which makes it useful for cases when dos.h is missing and you do not want to include windows.h just for a single function.
void sleep(int ms) { clock_t target = clock() + ms; while (clock() < target) { } }
Won’t that cause 100% CPU usage?
It will. That’s the price paid for ease of implementation in this case, which will still be bearable, if application only has to sleep for short periods of time, and use of unistd.h (unix) or windows.h (windows) isn’t preferred.