for C, is there a function that takes an int and doesn’t execute next statement ?
printf("a");
wait(500);
printf("b");
b will be printed after 500ms after a is printed out. something of the sort. sorry for the stupid question but i wasn’t sure how to go about searching for such function.
There is nothing like that in standard C. However, POSIX defines the
sleep()function (which takes an argument in seconds),usleep()(which takes an argument in microseconds), andnanosleep()(nanosecond resolution).It is also possible to use the
select()function withNULLfor all three file descriptor sets to sleep for sub-second periods, on older systems which don’t haveusleep()ornanosleep()(this is not so much a concern these days).