In a function, I have a static variable that I want to assign the time in seconds when a certain condition is met and keep that value until a different condition is met. The time value is a struct. Since now->sec is always incrementing, will timeWhenEventMadeActive below hold onto the initial value or will it increment everytime the function is called? I cant seem to test this.
1 2 3 4 5 6 7 8 9 10 11 12
static time_t timeWhenEventMadeActive = 0;
staticbool initTime = 0;
timeWhenEventMadeActive = now->sec; //holds uptime value in seconds
initTime = 1;
// some code.....
if((int)isOff == 1)
initTime = 0; // tries to reset timeWhenEventMadeActive