Answers for "sleep fractional seconds c"

C
1

c fractional sleep

#define _DEFAULT_SOURCE
#include "newSleep.h"

void fracSleep(float sec) {
    struct timespec ts;
    ts.tv_sec = (int) sec;
    ts.tv_nsec = (sec - ((int) sec)) * 1000000000;
    nanosleep(&ts,NULL);
}

fracSleep(0.5); //Half second delay
Posted by: Guest on October-27-2020

Code answers related to "C"

Browse Popular Code Answers by Language