标准库头文件:ctime

1.常用变量

clock_t    //进程运行clock时间
size_t    //sizeof运算符返回的无符号整数类型
time_t    //从纪元起的时间类型
tm    //日历时间类型
CLOCKS_PER_SEC    //每秒的处理器始时钟计次数 

2.常用操作

clock_t clock();    //返回自程序启动时处理器时钟时间,1000.0 * (end-start) / CLOCKS_PER_SEC得到ms数
time_t time( time_t* arg );    //返回系统当前时间和系统规定的起始时间作差,arg一般是nullptr
double difftime( time_t time_end, time_beg );    //计算时间之间的差,单位是s
tm* localtime( const time_t *time );//将time_t类型转换成tm类型
time_t mktime( tm* time );//将tm类型转换成time_t类型
char* ctime( const time_t* time );//转换time_t对象为文本表示,形式是Week M d h:m:s year
char* asctime( const tm* time_ptr );//转换tm对象为文本表示,形式是Week M d h:m:s year
size_t strftime( char* str, size_t count, const char* format, const tm* time );//转换tm对象到自定义的文本表示

 

发布了36 篇原创文章 · 获赞 6 · 访问量 6972

猜你喜欢

转载自blog.csdn.net/zhuikefeng/article/details/104758726