I am learning C and implementing a function where a variable is incremented at a certain period of time. However, I have been unable to find a solution that isn’t dependent on operating system (pthreads) or ones that are for C++ or C#. Additionally, I am unable to find a way that doesn’t use a function like usleep(); because I need to have this running with the rest of the program, not stopping it.
This is the function that I’ve written so far, but as mentioned I haven’t been able to find a solution.
int increment = 0;
void var_increment(){
// can't find a time based way
increment += 1;
}
lightleviathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.