Ok for integers because it pauses with resolution of seconds , so why use another type of argument?
Fortunately, you have several options, all in the POSIX standard:
#include <unistd.h>
int usleep(useconds_t usec);
that uses microseconds , or
#include <time.h>
int nanosleep(const struct timespec *req, struct timespec *rem);
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
Note that it uses nanoseconds : 1000000 nanoseconds = 1 millisecond.
Notice that, in both cases, the accuracy will hardly be exactly as requested; you will always be at the mercy of the workload of the system, your hardware clock, ... That is, the pause will always be something greater than the one requested.
EDITO
The usleep( )
function has been removed from the latest POSIX ; it is recommended to use the second, nanosleep( )
.