如何使用定时器使用C? [英] How to use timer in C?
本文介绍了如何使用定时器使用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是C中的方法,用户定时器?我需要等到500毫秒的工作。请mension什么好办法来做好这项工作。我用睡眠(3);
但这种方法并不在该时间段的任何工作。我有东西会尝试,直到那个时候得到任何输入。
What is the method to user timer in C? I need to wait until 500 ms for a job. Please mension any good way to do this job. I used sleep(3);
But this method does not do any work in that time duration. I have something that will try untill that time to get any input.
推荐答案
您可以使用 time_t的
struct和的 时钟()
从功能的 time.h中
You can use a time_t
struct and clock()
function from time.h.
使用时钟()存放在
并通过比较检查所经过的时间存储的时间和当前时间之间的区别。 time_t的
结构的启动时间
Store the start time in a time_t
struct by using clock()
and check the elapsed time by comparing the difference between stored time and current time.
这篇关于如何使用定时器使用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文