Loops/timers in C

2019-01-22 23:30发布

How does one create a timer in C?

I want a piece of code to continuously fetch data from a gps parsers output.

Are there good libraries for this or should it be self written?

7条回答
叛逆
2楼-- · 2019-01-22 23:55

The question about a timer is quite unspecific, though there are two functions that come to my mind that will help you:

  • sleep() This function will cause execution to stop for a specified number of seconds. You can also use usleep and nanosleep if you want to specify the sleeptime more exactly
  • gettimeofday() Using this function you are able to stop between to timesteps.

See manpages for further explanation :)

查看更多
登录 后发表回答