I want to execute 2 different output at a certain time in seconds. And change the swap time using keyEvent. Here's the idea.
![How to execute Time Loop in C without clock() and timer ?-gambar2-jpg](https://cboard.cprogramming.com/attachments/c-programming/15505d1539457062-how-execute-time-loop-c-without-clock-timer-gambar2-jpg?s=a1113900697edda481aff27c175cb5d8)
I've been looking for some advice online and I only find those with timer and clock(). I don't need to use timer and clock() since I already use a utilTimer library to count milliseconds as the program is executed.
Here's the my keyEvent code :
Code:
if (key == '1' ) {
mod=10;
}
if (key == '2' ) {
mod=5;
}
if (key == '3' ) {
mod=3;
}
if (key == '4' ) {
mod=1;
}
How do I implement the time loop ? As of now for the looping I'm using mod, but still a little bit confused and haven't achieved my goal.
Code:
for (int count = 0; true; count++) {
if (count % 10 == 0) {
//every 10 seconds
}
if (count % 5 == 0) {
// Every 5 seconds
}
}
Any advice ?