Timer in C 06-16-2013, 01:54 PM
#1
So.. I'm doing a timer function in C. I controlled the timer status via a global variable named timerStatus. But when I call the timer function it never stops even I set the value of timerStatus to 0. I think thats because of it is a recursive function.
C code is like this:
So my question is; How can I change the value of a variable outside from function while that function is on proccess.
Or any fix to this function is O.K
Thanks
C code is like this:
Code:
#include <stdio.h>
#include <windows.h>
int Timer(int);
int timerStatus = 0;
int main(void){
timerStatus = 1;
Timer(3000);
timerStatus = 0;
return 0;
}
int Timer(int interval){
if(timerStatus == 1){
Sleep(interval);
//Proccess goes here
printf("%s\n","Test");
Timer(interval);
}
return 0;
}
So my question is; How can I change the value of a variable outside from function while that function is on proccess.
Or any fix to this function is O.K

Thanks

Fuck You.