Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to implement the function of executing a function every x seconds with C?
How to implement the function of executing a function every x seconds with C?
You can use the delay () function or the sleep () function to complete the delay operation. Both functions take unsigned integer parameters. The parameter of the delay () function is 4 milliseconds, which is more accurate. The parameter of the sleep () function is seconds, which is convenient. For example, sleep(20) is a delay of 20 seconds, and sleep can be called before this function every 20 seconds. This will achieve your goal, pay attention to the beginning with # include.