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;
- }
-
-