创建在C定时器 [英] Creating a Timer in C

查看:192
本文介绍了创建在C定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个定时器?计时器像在Visual Basic中;你设置的时间间隔,如果定时器启用了等待,直到时间到了。

How do I create a timer? A timer like the one in Visual Basic; you set an interval, if the timer is enabled it waits until the time is up.

我不希望因为我想知道它是如何工作使用现有的库。

I don't want to use an existing library because I want to know how it works.

所以..我只是希望有人能解释我是如何工作的定时器,也许给我code的例子来创建自己的 - 如果不是太先进

So.. I just hope someone could explain me how timers work and maybe give me an example of code to create my own - if it's not too advanced.

编辑:
我想创建一个用于Linux系统。

I wanna create one for a linux system.

推荐答案

您可以做到这一点。

#include <stdio.h>
#include <unistd.h>

int main() {
    printf("wait\n");
    sleep(3);
    printf("time elapsed\n");
    return 0;
}

这篇关于创建在C定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆