struct timeval{
long int tv_sec; // 秒数 同time(NULL) 的返回值
long int tv_usec; // 微秒数 10 的6次方
};
 struct timezone{
int tz_minuteswest;/*格林威治时间往西方的时差*/
int tz_dsttime;/*DST 时间的修正方式*/
};
 #include <stdio.h>
#include <sys/time.h> int main()
{
struct timeval tv;
struct timezone tz; int res = gettimeofday(&tv, &tz);
printf("res = %d\n", res);
printf("tv.tv_sec = %ld, tv.tv_usec = %ld\n",
tv.tv_sec, tv.tv_usec); return ;
}

gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用的更多相关文章

  1. redis获取当前时间精确到微秒

    在redis取得当前时的方法为执行time命令 127.0.0.1:6382> time1) "1495780564"2) "894089" 第一行为以 ...

  2. VC++ 获取系统时间、程序运行时间(精确到秒,毫秒)的五种方法

    1.使用CTime类(获取系统当前时间,精确到秒) CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime();//获取系统日期 str=tm ...

  3. 【VS开发】VC++ 获取系统时间、程序运行时间(精确到秒,毫秒)的五种方法

    1.使用CTime类(获取系统当前时间,精确到秒) CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime();//获取系统日期 str=tm ...

  4. 【转】cocos2d-x获取系统时间——2013-08-25 10

    欢迎转载,本帖地址:http://blog.csdn.net/jinjian2009/article/details/9449585 之前使用过cocos2d-x获取系统时间,毫秒级的 long ge ...

  5. cocos2d-x获取系统时间

    欢迎转载,本帖地址:http://blog.csdn.net/jinjian2009/article/details/9449585 之前使用过cocos2d-x获取系统时间,毫秒级的 long ge ...

  6. C/C++ 获取系统时间 到秒 || 到毫秒

    string getNowSysTime(string &outPut) { ] = {}; struct timeval tv; struct timezone tz; struct tm ...

  7. (C/C++学习)12.获取系统时间制作时钟(system()略解)

    说明:通过调用函数来获取系统当前时间,并制作一个数字式的时钟,时钟的显示包括年.月.日.小时.分以及秒,通过系统屏幕的刷新来对不断更新的时间进行屏幕的显示. 一.对相关函数的学习 1.time_t t ...

  8. cocos2d-x 获取系统时间

    转自:http://blog.csdn.net/jinjian2009/article/details/9449585 之前使用过cocos2d-x获取系统时间,毫秒级的 long getCurren ...

  9. C++11新特性,利用std::chrono精简传统获取系统时间的方法

    一.传统的获取系统时间的方法 传统的C++获取时间的方法须要分平台来定义. 相信百度代码也不少. 我自己写了下,例如以下. const std::string getCurrentSystemTime ...

随机推荐

  1. Entity Framework只entity与DbContext的分离

    说明:以下例子采用的是DB first的模式 在之前的webform开发模式中我们习惯性性的会建立这样的一些类库:Model.DAL.BLL...但是在用了EF以后,我们创建的ADO.NET实体数据模 ...

  2. 题目1049:字符串去特定字符——九度OJ

    题目1049:字符串去特定字符 http://ac.jobdu.com/problem.php?pid=1049 时间限制:1 秒 内存限制:32 兆 题目描述: 输入字符串s和字符c,要求去掉s中所 ...

  3. 【转】使用itms-services从浏览器发布iOS App遇到的问题总结

    itms-service是apple为iOS企业用户($299)提供的无线分发安装方式所使用的协议,使用这种方式发布应用不需要通过App Store,任何iOS设备都可以安装企业用户通过这种方式发布的 ...

  4. Format可能存在的坑

    import java.text.MessageFormat; public class TestFormat { public static void main(String[] args) { / ...

  5. serialVersionUID 的用途--转加自己的疑问

    serialVersionUID适用于Java的序列化机制.简单来说,Java的序列化机制是通过判断类的serialVersionUID来验证版本一致性的.在进行反序列化时,JVM会把传来的字节流中的 ...

  6. Hive(二):windows hive ODBC 安装

    针对Windows 32位和64位的系统对应有多个版本的 Hive ODBC Connector, 在安装的过程中,版本必须完全匹配(即:32位的 connector 只能在32位的系统运行,64位的 ...

  7. Ruby Exception

    begin #可能发生异常的地方 rescue #如何处理异常 end rescue,哈哈,太有爱的一个单词了... begin #可能发生异常的地方 rescue => exception # ...

  8. HackerRank "Self Balancing Tree"

    Something to learn: Rotation ops in AVL tree does not require recursion. https://github.com/andreima ...

  9. LintCode "Heapify"

    My first try was, using partial sort to figure out numbers layer by layer in the heap.. it only fail ...

  10. bzoj3034: Heaven Cow与God Bull

    Description __int64 ago,there's a heaven cow called sjy...A god bull named wzc fell in love with her ...