一个简单的 c语言 问题

FromXAStart 2012-03-11 02:16:19
我想实现 闹钟 这样的一个功能:

对于 时间相关的 c 函数(计时函数), 我不是很熟悉, 麻烦 大侠们 给个提示或者Demo。
...全文
158 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
FromXAStart 2012-03-11
  • 打赏
  • 举报
回复
到 晚上 8点 9点 10点 分别提示的那种?
pengfoo 2012-03-11
  • 打赏
  • 举报
回复

#include <time.h>
#include <stdio.h>

int main(void)
{
int n=60;
while(n>0)
{
long t=time(NULL);
t+=1;
while(time(NULL)<t)
;
n--;
}
return 0;
}


这样好看点。。或者直接sleep(倒计时的时间),行不行?
pengfoo 2012-03-11
  • 打赏
  • 举报
回复
//倒计时1分钟程序demo
#include <time.h>
#include <stdio.h>

int main(void)
{
int n=60;
while(n>0)
{
long t=time(NULL);
t+=1;
while(time(NULL)<t)
;
n--;
}
return 0;
}
pengfoo 2012-03-11
  • 打赏
  • 举报
回复
#include <time.h>

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧