25、记录时间的几种方法
2011-09-04 17:23
169 查看
方法一:
View Code
方法二:
方法三:
View Code
#include <time.h> #include <stdio.h> void main( void ) { time_t ltime; time( <ime ); printf( "The time is %s\n", ctime(<ime ) ); }
方法二:
struct timeval start; struct timeval end; float time_use = 0; gettimeofday(&start,NULL); //do some operation gettimeofday(&end,NULL); time_use = end.tv_sec - start.tv_sec; //in sec
方法三:
struct tm *local; time_t t; time(&t); local=localtime(&t); char ctime[30]; memset(ctime, 0, 30); sprintf(time, "[%d:%d:%d]",local->tm_hour, local->tm_min, local->tm_sec); cout << time;
相关文章推荐
- python记录程序运行时间的几种方法
- Oracle多行记录字符串综合操作几种方法
- JAVA获得当前时间的几种方法
- Oracle多行记录合并/连接/聚合字符串的几种方法[转]
- SQL重复记录查询的几种方法
- 获取系统时间的几种方法!!!
- 几种时间戳转换时间格式的方法
- c/c++在windows下获取时间和计算时间差的几种方法总结
- c/c++在windows下获取时间和计算时间差的几种方法总结
- spring boot aop 记录方法执行时间
- 记录:js删除数组中某一项或几项的几种方法
- java向MySQL插入当前时间的四种方式和java时间日期格式化的几种方法(案例说明)
- MySql避免重复插入记录的几种方法
- Oracle字段转字符串/多行记录合并/连接/聚合字符串的几种方法
- 记录:js删除数组中某一项或几项的几种方法
- java中获取时间的几种方法
- Oracle 数据库中,不同数据库的表间记录进行复制或迁移时会用以下几种方法:
- C++ 计算 代码运行时间的 几种方法
- 前段时间看到的一个处理GIF图像的方法,记录一下
- Win7系统查看最后登录时间的方法 win7电脑记录用户登录时间的查看