-4

In python the time.sleep() is for count down time before execute next code:

import time
time.sleep(5)
print("something")

So what is the equivalent to that in C++. Sorry for asking this simple question but I am new to C++

Tab135
  • 21
  • 3

1 Answers1

2

The "sleep_for" allows you to give the time you want to delay, and "sleep_until" allows you to delay until a exact time. #include #include

int main() {
    using namespace std::this_thread; // sleep_for, sleep_until
    using namespace std::chrono; // nanoseconds, system_clock, seconds

    sleep_for(nanoseconds(10));
    sleep_until(system_clock::now() + seconds(1));
}
TudorTeo
  • 133
  • 2
  • 12