揮発性のメモ2

最近知った知識を さも昔から知ってた風にメモ書きしていく

2024-05-20から1日間の記事一覧

Cで、ミリ秒スリープする

#include <stdio.h> #include <time.h> #include <signal.h> #include <errno.h> /// ちゃんとミリ秒寝る関数 int sleep_msec(long long msec) { struct timespec ts; ts.tv_sec = msec/1000; ts.tv_nsec = (msec%1000)*1000000; int result; for(;;){ result = nanosleep(&ts, &ts); if(result==</errno.h></signal.h></time.h></stdio.h>…