struct timeval 和 struct timespec
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
測试代码例如以下:
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
int main(int argc,char * argv[]){
struct timeval tv;
while(1){
gettimeofday(&tv,NULL);
printf("time %u:%u/n",tv.tv_sec,tv.tv_usec);
sleep(2);
}
return 0;
}
执行结果例如以下:
time 1259471701:970193
time 1259471703:971529
time 1259471705:973225
time 1259471707:974921
timespec
struct timespec
{
time_t tv_sec;
long int tv_nsec;
};
与struct timeval 不同,将结构体内成员微秒变换成纳秒
struct timeval 和 struct timespec的更多相关文章
- gettimeofday(struct timeval *tv, struct timezone *tz)函数
gettimeofday(struct timeval *tv, struct timezone *tz)函数 功能:获取当前精确时间(Unix时间) 其中: timeval为时间 truct tim ...
- struct timespec 和 struct timeval
time()提供了秒级的精确度 . 1.头文件 <time.h> 2.函数原型 time_t time(time_t * timer) 函数返回从TC1970-1-1 0:0:0开始到现在 ...
- linux高精度struct timespec 和 struct timeval
一.struct timespec 定义: typedef long time_t;#ifndef _TIMESPEC#define _TIMESPECstruct timespec {time_t ...
- struct timeval和gettimeofday()
http://www.cppblog.com/lynch/archive/2011/08/05/152520.html struct timeval结构体在time.h中的定义为: struct ti ...
- struct timeval和gettimeofday
struct timeval和gettimeofday() struct timeval结构体在time.h中的定义为: struct timeval { time_t tv_sec; /* Seco ...
- [c++]struct timeval
struct timeval { time_t tv_sec; // seconds long tv_usec; // microseconds }; re 1. struct timespec 和 ...
- struct timeval结构体 以及 gettimeofday()函数(转)
struct timeval结构体 转载地址:http://blog.chinaunix.net/uid-20548989-id-2533161.html 该结构体是Linux系统中定义,struct ...
- struct timeval 计时问题
linux编程中,如果用到计时,可以用struct timeval获取系统时间.struct timeval的函数原型如下: struct timeval { __kernel_time_t tv_s ...
- struct inode 和 struct file
1.struct inode──字符设备驱动相关的重要结构介绍 内核中用inode结构表示具体的文件,而用file结构表示打开的文件描述符.Linux2.6.27内核中,inode结构体具体定义如下: ...
随机推荐
- GridView 动态绑定控件 OnRowCommand事件触发
主题:GridView动态生成的控件不能触发OnRowCommand事件,且点击控件按钮后,控件的值会消失. 案例, 由于公司需要绑定的数据列顺序是动态生成的,且有的数据列需要绑定Button控件.所 ...
- 改变querystring值,然后重定向
原文发布时间为:2009-11-13 -- 来源于本人的百度文章 [由搬家工具导入] 本页面改变querystring值,然后重定向 本页面,避免出现重复querystring。。 如避免出现 www ...
- Syslinux使用
1. 介绍 Syslinux是一个功能强大的引导加载程序, 可以装在U盘上来引导系统 在5.00版本以前,几乎所有c32模块是独立的,即没有其他模块依赖:但在5.00以后,很多c32模块则是依赖于其他 ...
- 老郭带你学数据结构(C语言系列)2-线性表之动态顺序表
一.基本概念: 线性表:由n个类型相同的数据元素组成的有限序列,记为(a1,a2,--an). 线性表的特征:其中的元素存在这序偶关系,元素之间存在着严格的次序关系. 顺序存储表:线性表中的元素依次存 ...
- no update
cd /home/.gnupg/ mv gpg.conf gpgbake.conf pacman -S archlinux-keyring && pacman -Syu 如果还是不行, ...
- hdu 4528(搜索好题)
小明系列故事——捉迷藏 Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total S ...
- Android代码中设置字体大小,字体颜色,显示两种颜色.倒计时效果
Android代码中设置字体大小,字体颜色,显示两种颜色 在xml文件中字体大小用的像素 <TextView android:id="@+id/uppaid_time" an ...
- 在delphi中,如何把十进制数转换为十六进制整形数。若用inttohex只能转化为十六进制字符串。
var b: Byte; s: string;begin s := '31'; //16进制字符串 b := StrToInt('$' + s);end; 不过要注意一点,如果在程序调试时想看b的值, ...
- mysql日常运维与参数调优
日常运维 DBA运维工作 日常 导数据,数据修改,表结构变更 加权限,问题处理 其它 数据库选型部署,设计,监控,备份,优化等 日常运维工作: 导数据及注意事项 数据修改及注意事项 表结构变更及注意事 ...
- 深入浅出 Cocoa 之 Core Data(1)- 框架详解
深入浅出 Cocoa 之 Core Data(1)- 框架详解 罗朝辉(http://blog.csdn.net/kesalin) CC 许可,转载请注明出处 Core data 是 Cocoa 中处 ...