Actually, the clock() function is a portable function, but <clock.h> is not a standard header. Rather, the clock() function is found in <time.h>.
Also, clock() returns the *processor time used*(not the system time). So, Swap's example is portable (minus the non-standard header <clock.h>).
The caveat is that it is very processor intensive and probably won't give the accuracy that you'll want. Typically an implementation will provide its own extensions for accomplishing what you want.
POSIX provides a sleep() that sleeps for the number of seconds in its argument:
#include <unistd.h>
/* ... */
sleep(5); /* Process is put to sleep for 5 seconds */
POSIX also provides alarm() and signal() if you're looking for a solution where the process does other processing and periodically does something else:
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
/* ... */
static volatile sig_atomic_t woken_up;
void handler(int sig)
{
woken_up=1;
}
int main(void)
{
signal(SIGALRM,handler);
woken_up=1;
for (;

{
if (woken_up) {
puts("doing other processing"

;
alarm(5); /* A SIGALRM will be sent to the process in 5 seconds */
woken_up=0;
}
/* Do other processing */
}
return 0;
}
If you need more precise resolution, there's a BSD function called usleep() that your system might provide which sleeps for N microseconds.
Of course, most of the above will probably not be offered by DOS/Win32 implementations, but I'm sure you'll find comparable functions with different names.
Russ
bobbitts@hotmail.com