c中time.h函数

今天看了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中的。 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值