I wonder if someone would be kind enough to help me with a "timer" problem.
Briefly, I want to start a program passing it a delay in seconds as an argument, and a batch file (or similar) to carry out at the elapsed time. (eg. prog 10 do_it.bat)
I've got the following funtion in main:
void snooze( clock_t wait ) {
clock_t targ;
targ = wait + clock();
while( targ > clock() ) {
/* wait ! */
}
}
which is called thus:
snooze((clock_t)nSecs * CLOCKS_PER_SEC); (where nSecs is argv[1])
and everything's lovely....BUT then I tried to do something else on the computer whilst running it and my CPU's 98.9% used !!
Can anyone suggest a better way of doing this please - there's no real urgency, it's just something I wanted to do 'cos I figured it would be interesting !