转载地址:http://blog.chinaunix.net/uid-20548989-id-2533161.html
该结构体是Linux系统中定义,struct timeval结构体在time.h中的定义为:
- struct timeval
- {
- __time_t tv_sec; /* Seconds. */
- __suseconds_t tv_usec; /* Microseconds. */
- };
- #include <sys/time.h>
- #include <stdio.h>
- int
- main(void)
- {
- int i;
- struct timeval tv;
- for(i = 0; i < 4; i++){
- gettimeofday(&tv, NULL);
- printf("%d\t%d\n", tv.tv_usec, tv.tv_sec);
- sleep(1);
- }
- return 0;
- }