今天看了time.h函数,对里面的方法看的糊里糊涂。不是很会用chm的。在网上找个找,看见不错的东西。下面是链接。
http://blog.youkuaiyun.com/wangluojisuan/article/details/7045592
在这个链接中,我有几个无法编译。
#include <time.h>
02.#include <stdio.h>
03.#include <dos.h>
04.#include <conio.h>
05.int main() {
06. time_t first, second;
07. clrscr(); //应该给为sysem("cls");否则在VC下无法识别。
08. first=time(NULL);
09. delay(2000);
10. second=time(NULL);
11. printf("The difference is: %f seconds",difftime(second,first));
12. getch();
13. return 0;
14.}
另外一个是
#include <time.h>
#include <stdio.h>
#include <dos.h>
int main() {
time_t t;
t=time();
//time()的原型是time_t time( time_t *time ),time_t是一个long类型,如果使用必须给time(),*time=NULL,表示当前的日历时间。
//默认是从1970-1-1到现在的时间,按秒算的。localtime()转下(1)
printf("The number of seconds since January 1,1970 is %ld",t);
return 0;
}
(1)struct tm *localtime(const time_t *timer)返回tm结构体的时间信息。
(2)char *asctime( const struct tm *ptr );则是能够将tm结构体的信息以字符数组输入。
另外提供几个信息。delay(),该函数是TC下特有的函数,VC下应使用Sleep()函数.VC下清屏可以使用system("CLS");这是在window.h中的。