I don\'t know exactly how to word a search for this.. so I haven\'t had any luck finding anything.. :S
I need to implement a time delay in C.
for example I w
C11 has a function specifically for this:
#include
#include
#include
void sleep(time_t seconds) {
struct timespec time;
time.tv_sec = seconds;
time.tv_nsec = 0;
while (thrd_sleep(&time, &time)) {}
}
int main() {
puts("Sleeping for 5 seconds...");
sleep(5);
puts("Done!");
return 0;
}
Note that this is only available starting in glibc 2.28.