2025年5月21日 星期三 乙巳(蛇)年 二月廿三 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > C语言

ubuntu中C语言获得时间

时间:04-17来源:作者:点击数:70

ubuntu中C语言获得时间

  • #include <stdio.h> // C标准库用来调用printf
  • #include <sys/time.h> // gettimeofday()的头文件
  • #include <unistd.h> // 加入延迟更加方便我们观察
  • int main()
  • {
  • struct timeval start, end;
  • gettimeofday( &start, NULL );
  • printf("start : %d.%d\n", start.tv_sec, start.tv_usec);
  • sleep(5);
  • gettimeofday( &end, NULL );
  • printf("end : %d.%d\n", end.tv_sec, end.tv_usec);
  • return 0;
  • }
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门