上記の操作をミリ秒単位で行いたいと考えています。どのライブラリと関数呼び出しを優先する必要がありますか?
質問する
34095 次
3 に答える
22
EDIT 2017: C++11 sleep_for
is the right way to do this. Please see Xornad's answer, below.
C++03:
Since Mac OS X is Unix-based, you can almost always just use the standard linux functions!
In this case you can use usleep
(which takes a time in microseconds) and just multiply your milliseconds by 1000 to get microseconds.
#include <unistd.h>
int main () {
usleep(1000); // will sleep for 1 ms
usleep(1); // will sleep for 0.001 ms
usleep(1000000); // will sleep for 1 s
}
For more info on this function, check out the Linux man page:
于 2013-10-18T02:14:49.693 に答える
0
ナノ秒またはマイクロ秒が必要でない限り、sleep(integer または number) を使用してください
于 2020-12-03T00:08:07.087 に答える