Sleep alternatives

Hi, i'm new to this forum and i had a question.

Are there any Sleep() alternatives?
Because to me it seems like C++ should have a similar purpose comand.
Well if you're up to date as far as C++11, you can do this.
http://www.cplusplus.com/reference/thread/this_thread/sleep_for/
sleep is standard as well (dated). Sleep (caps!) is microsoftism I think.
sleep is standard

Yeah, but it's POSIX, not ISO C++.

http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html
thanks a lot
There's std::this_thread::sleep_for, and std::this_thread::sleep_until.

Both are for manipulating the execution of a thread.

https://en.cppreference.com/w/cpp/thread/sleep_for
https://en.cppreference.com/w/cpp/thread/sleep_until
Last edited on
Use the <thread> libraries to do it, as salem c and Furry Guy pointed to you. Be aware, using them might incur linking additional OS libraries.

If you want to use OS libraries directly, Sleep() is Microsoft’s and usleep() is POSIX. Examples of use:
http://www.cplusplus.com/forum/beginner/139609/#msg738550

The POSIX sleep() is a very crude timer. Avoid it.
Topic archived. No new replies allowed.