C++编程问题 头文件

来源:百度知道 编辑:UC知道 时间:2024/05/30 14:59:40
#include<ctime>帮忙下,我想知道这个头文件里函数的作用和用法
就是这些函数:

using ::clock_t;
using ::time_t;
using ::tm;

using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
using ::strftime;

C语言的标准库函数包括一系列日期和时间处理函数,它们都在头文件中说明。下面列出了这些函数。在头文件中定义了三种类型:time_t,struct tm和clock_t。

在中说明的C语言时间函数

time_t time(time_t *timer);

double difftime(time_t time1,time_t time2);

struct tm *gmtime(const time_t *timer);

struct tm *localtime(const time_t *timer);

char *asctime(const struct tm *timeptr);

char *ctime(const time_t *timer);

size_t strftime(char *s,size_t maxsize,const char *format,const struct tm *timeptr);

time_t mktime(struct tm *timeptr);

clock_t clock(void);

下面是我从网上收集到的时间函数集

asctime(将时间和日期以字符串格式表示)
相关函数
time,ctime,gmtime,localtime
表头文件
#i nclude
定义函数
char * asctime(const struct tm * timeptr);
函数说明
asctime()将参数timeptr所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。此函数已经由时区转换成当地时间,字符串格式为:"Wed Jun 30 21:49:08 1993\n"
返回值
若再调用相关的时间日期函数,此字符串可能会被破坏。此函数与ctime不同处在于传入的参数是不同的结