- 日期和时间转换函数 asctime
函数原型:char * asctime(const struct tm *tblock)
#include<stdio.h>
#include<string.h>
#include<time.h>
int main(void)
{
struct tm t;
char str[60];
t.tm_sec = 1;
t.tm_min = 30;
t.tm_hour = 9;
t.tm_mday = 22;
t.tm_mon = 11;
t.tm_year = 56;
strcpy(str, asctime(&t));
printf("%s\n",str);
}
- 测定运行时间的函数
函数原型: clock_t clock(void);
功能: 确定所用的处理器时间,也就是在运行时获得当前处理器时间
例:
#include<stdio.h>
#include<time.h>
#include<dos.h>
int main(void)
{
clock_t start, end;
start = clock();
delay(3000);
end = clock();
printf("The time was %f \n",(end - start) / CLK_TCK);
}