std::this_thread::sleep_for() Or usleep()
What would be better to be used in main()? This may be very silly but i am new to C++11 features.
std::this_thread::sleep_for() Or usleep()
What would be better to be used in main()? This may be very silly but i am new to C++11 features.
Copyright © 2021 Jogjafile Inc.
The former is actually a portable C++ function. The latter is an obsolete, non-portable POSIX function (replaced by
nanosleep
, which remains non-portable). Usestd::this_thread::sleep_for()
, which will likely be implemented in terms ofnanosleep
when available/appropriate, or whatever other function the system provides otherwise.