c语言getdate函数 c语言中get函数的用法( 三 )


函数138 。sin()
函数139 。sprintf()格式化输出到数组的函数
函数140 。strcat()
函数141 。tan()
函数142 。_write()写文件函数
函数143 。write()写文件函数
原文释义请到百度文库里搜寻字串“C语言常用函数”后下载
函数51-60因原注里排序号码少编,所以只有133个常用函数 。
DOC大小是119.5KB
贡献时间:2010-09-10
贡献者:handanlinzhang
用c语言写一个动态时间表,要源代码用到的数据结构:
time_t是一个long类型 代表机器时间,可由time( )函数获得 。
日历时间用一个(char *) 类型的字符串表示 。格式为:星期 月 日 小时:分:秒 年\n\0
可由函数ctime( ) asctime( ) 得到 。
以tm结构表达的时间,结构tm定义如下:
structtm{可由函数localtime( ), gmtime( )得到
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;};
//系统日期
structdate{
intda_year;/*Year - 1980 */
charda_day;/*Day of the month */
charda_mon;/* Month (1 = Jan) */};
//系统时间
structtime{
unsigned char ti_min;/* Minutes */
unsigned char ti_hour;/* Hours */
unsigned char ti_hund; /* Hundredths of seconds */
unsigned charti_sec;/* Seconds */};
用到的函数:
char * asctime(struct tm * ptr)将tm结构的时间转化为日历时间 。
char *ctime(long time)将机器时间转化为日历时间 。
struct tm *gmtime(time_t*time) 将机器时间转化为tm时间
当ptr为空时,得到机器时间;非空时,设置机器时间 。
time_ttime(time_t *ptr)得到或设置机器时间
double difftime(time_t time2, time_t time1) 得到两次机器时间差,单位为秒
long dostounix(struct data *d, struct time *t) 将DOS的日期和时间格式转换成UNIX标准
(机器时间(用到dos.h库).void unixtodos(long utime, struct date *d, struct time *t)
将UNIX格式的时间和日期转换成DOS格式(由time 和date两部分组成,只能由机器时间得到,并且用到dos.h库)
void getdate(struct date *d) 得到系统日期,d 存放得到的日期信息
void setdate(struct date *d)
void gettime(struct date *t) 得到系统时间 d 存放得到的时间信息
void settime(struct date *t)
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不同处在于传入的参数是不同的结构 。
附加说明
返回一字符串表示目前当地的时间日期 。

推荐阅读