My question is similiar to the one recently posted about waiting for x milliseconds. I have an idea of how to make a program wait for X minutes, but I would like to hear others opinions or suggestions about how to do this. The following function works, but it continously has the processor checking the time, and Im wondering if there is a better way where the processor does nothing without getting into operating specific functions.
#include <time.h>[/color purple]
void[/color green] Wait_X_Minutes (double[/color green] num_min)
/*Program should wait X minutes without doing anything*/[/color blue]
{
clock_t[/color green] start_time;
double[/color green] lapsed_time;
start_time = clock();
for (;[/color red]
{
lapsed_time = (double)[/color green] (clock() - start_time)/CLOCKS_PER_SEC;
if (lapsed_time > num_min*60.0)
break;
}
}
Thanks
Zub
#include <time.h>[/color purple]
void[/color green] Wait_X_Minutes (double[/color green] num_min)
/*Program should wait X minutes without doing anything*/[/color blue]
{
clock_t[/color green] start_time;
double[/color green] lapsed_time;
start_time = clock();
for (;[/color red]
{
lapsed_time = (double)[/color green] (clock() - start_time)/CLOCKS_PER_SEC;
if (lapsed_time > num_min*60.0)
break;
}
}
Thanks
Zub