vc中获取当前时间戳
时间: 2023-11-23 13:57:24 浏览: 73
以下是在VC中获取当前时间戳的两种方法:
1. 使用gettimeofday获取时间戳初步封装:
```c
double GetTimeStamp(void) {
double timestamp;
struct timeval time_v;
gettimeofday(&time_v, NULL);
timestamp = (time_v.tv_sec) + (time_v.tv_usec) / 1000000.0;
return timestamp;
}
```
2. 使用gettimeofday基本使用:
```c
#include <sys/time.h>
double timestamp;
struct timeval time_v;
gettimeofday(&time_v, NULL);
timestamp = time_v.tv_sec * 1000 + time_v.tv_usec / 1000;
printf("now time: %lf\n", timestamp);
```
阅读全文