With the code below I want to execute a task if the day is saturday and if the minute is >= 14.
There is 2 things I wonder here.
The code below is an infinite loop that never stops. So it checks for if this criteria is true but when the criteria is true nothing happens.
And more important. This cant be the way to do this because the processor is peeking all the time since it is a loop that is running.
How is it possible to check for this criteria without letting the processor "work"/peek ?
int Day;
int Minute;
time_t now = time(0);
struct tm* tm = localtime(&now);
for( int i = 0; i < 5; i++)
{
i = i - 1;
Day = tm->tm_wday;
Minute = tm->tm_min;
if( Day == 6 && Minute >= 14 )
{
//Execute task
}
}
Check out this related thread