#includesys/time.h/*struct timeval{__time_t tv_sec; Seconds. 秒位部分__suseconds_t tv_usec; Microseconds. 微秒位部分};*/void fn(){struct timeval now;gettimeofday(now, NULL); //获取从1970年1...

#include<sys/time.h>
/*
struct timeval
{
__time_t tv_sec; Seconds. 秒位部分
__suseconds_t tv_usec; Microseconds. 微秒位部分
};
*/
void fn(){
struct timeval now;
gettimeofday(&now, NULL); //获取从1970年1月1日到现在的时间
cout<<"当前的时间是"<<(long)now.tv_sec*1000 + (long)now.tv_usec/1000<<"毫秒"<<endl;
}
织梦狗教程
本文标题为:c/c++ linux下获取时间


基础教程推荐
猜你喜欢
- 全面了解C语言 static 关键字 2023-03-26
- [C语言]二叉搜索树 2023-09-07
- C语言编程C++旋转字符操作串示例详解 2022-11-20
- C语言实现宾馆管理系统课程设计 2023-03-13
- C++实战之二进制数据处理与封装 2023-05-29
- C语言 详解字符串基础 2023-03-27
- centos 7 vscode cmake 编译c++工程 2023-09-17
- 带你深度走入C语言取整以及4种函数 2022-09-17
- [c语言-函数]不定量参数 2023-09-08
- C++实现ETW进行进程变动监控详解 2023-05-15