| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1729 人关注过本帖
标题:"stdlib.h","math.h"和"time.h"
只看楼主 加入收藏
yjbqq
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-10-10
收藏
 问题点数:0 回复次数:5 
"stdlib.h","math.h"和"time.h"
#include"stdlib.h"
#include "math.h"
#include "time.h"
都有什么用?
搜索更多相关主题的帖子: math stdlib time include 
2006-10-12 00:18
神经塔
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1986
专家分:4
注 册:2006-7-1
收藏
得分:0 

这些都是些库文件,里面有你能用的函数!


[shadow=255,red,2]待到秋来九月八,我花开时百花杀。冲天香阵透长安,满城尽是黄金甲。 [/shadow]
2006-10-12 00:19
yjbqq
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-10-10
收藏
得分:0 
具体一点嘛

抵制日货,从我做起!!!
2006-10-12 00:28
unicorn
Rank: 4
等 级:贵宾
威 望:14
帖 子:1066
专家分:0
注 册:2005-10-25
收藏
得分:0 

math.h是数学函数头文件可以帮助求一些运算的例如开方,取模,求绝对值等 具体包含哪些数学函数和使用方法你可以查查书的

stdlib.h 是系统函数头文件包括exit 和itoa

exit是结束程序且返回值将被忽略
原型: void exit(int retval);



#include <stdlib.h>

main()
{
int i;
for(i=0;i<10;i++)
{
if(i==5) exit(0);//结束程序
else
{
clrscr();
printf(\"%d\",i);
getchar();
}
}

getchar();
return 0;
}




itoa是把整数i转换成字符串,返回指向转换后的字符串的指针
原型:char *itoa(int i);

例如:
#include <stdlib.h>

main()
{
int i=7412;

printf(\"%d\",i);
printf(\"%s\",itoa(i));//把i转换为字符串并输出

getchar();
return 0;
}





time.h是包含与时间相关的函数

函数体有:

time_t time(time_t *); 获取当前时间为一个长整数
char * ctime(const time_t *);将时间结构time_t转换为字符串
char * asctime(const struct tm *);将tm结构转换为字符串
struct tm * gmtime(const time_t *);将时间结构转换为tm结构 GMT
struct tm * localtime(const time_t *);将时间结构转换为tm结构 LT
time_t mktime(struct tm *);将tm结构转换为time_t结构
double difftime(time_t, time_t);将前一个减去后一个的差额
clock_t clock(void);返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock tick)数

tm结构:
struct tm {
int tm_sec; /* seconds after the minute - [0,59] * /
int tm_min; /* minutes after the hour - [0,59] * /
int tm_hour; /* hours since midnight - [0,23] * /
int tm_mday; /* day of the month - [1,31] * /
int tm_mon; /* months since January - [0,11] * /
int tm_year; /* years since 1900 * /
int tm_wday; /* days since Sunday - [0,6] * /
int tm_yday; /* days since January 1 - [0,365] * /
int tm_isdst; /* daylight savings time flag * /
};


例如:

#include <time.h>

main()
{
time_t now;
{
struct tm *l_time;
char string1[20];
time(&now);
l_time = localtime(&now);
strftime(string1, sizeof string1, \"%d/%b/%y\n\", l_time);
printf(\"The current date is %s\", string1);
}
}//结果为The current date is 12/Oct/06



unicorn-h.spaces. ◇◆ sava-scratch.spaces.  noh enol ! pue pu!w hw u! shemle aq ll!m noh 
2006-10-12 16:35
yjbqq
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-10-10
收藏
得分:0 
太感谢了!~~

抵制日货,从我做起!!!
2006-10-12 17:21
bestboy555
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2006-8-1
收藏
得分:0 
谢谢

原来这个世界还有好多真理!
2006-10-12 17:24
快速回复:"stdlib.h","math.h"和"time.h"
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017971 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved