linux —— C编程

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux —— C编程相关的知识,希望对你有一定的参考价值。

目录:1、获取毫秒时间

 


 

1、获取毫秒时间

  1. #include <stdio.h>
  2. #include <sys/time.h>
  3.  
  4. int main() {
  5.     struct timeval start, end;
  6.     gettimeofday( &start, NULL );
  7.     sleep(3);
  8.     gettimeofday( &end, NULL );
  9.     int timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
  10.     printf("time: %d us\n", timeuse);
  11.     return 0;
  12. }

参考:博客

以上是关于linux —— C编程的主要内容,如果未能解决你的问题,请参考以下文章