📄 get_time.h
字号:
/*
@ 函数名:get_time 程序员:张军 时间:2009年3月13日
@ 该函数用于读取系统时间,包括年,月,日,时,分,秒。
@ year:传出参数,表示年分的整数。
@ month:传出参数,表示月份的整数。
@ day:传出参数,表示日的整数
@ hour:传出参数,表示时的整数
@ minute:传出参数,表示分的整数
@ second:传出参数,表示秒的整数
*/
#define TIME_LEN 6
void get_time(int* year ,int* month ,int* day ,int* hour ,int* minute ,int* second)
{
time_t timep;
struct tm * system_time;
timep=time(NULL);
system_time=(struct tm *)malloc(sizeof(struct tm));
system_time=localtime(&timep);
*year=system_time->tm_year+1900;
*month=system_time->tm_mon+1;
*day=system_time->tm_mday;
*hour=system_time->tm_hour;
*minute=system_time->tm_min;
*second=system_time->tm_sec;
}
/*
@ 函数名:get_time_str 程序员:张军 时间:2009年3月13日
@ 该函数用于读取系统时间,包括年,月,日,时,分,秒。
@ stryear:传出参数,表示年分的字符串。
@ strmonth:传出参数,表示月份的字符串。
@ strday:传出参数,表示日的字符串。
@ strhour:传出参数,表示时的字符串。
@ strminute:传出参数,表示分的字符串。
@ strsecond:传出参数,表示秒的字符串。
*/
void get_time_str(char* stryear,char* strmonth ,char* strday ,char* strhour ,char* strminute ,char* strsecond)
{
time_t timep;
struct tm * system_time;
timep=time(NULL);
system_time=(struct tm *)malloc(sizeof(struct tm));
system_time=localtime(&timep);
memset(stryear,0,TIME_LEN-1);
memset(strmonth,0,TIME_LEN-1);
memset(strday,0,TIME_LEN-1);
memset(strhour,0,TIME_LEN-1);
memset(strminute,0,TIME_LEN-1);
memset(strsecond,0,TIME_LEN-1);
sprintf(stryear,"%d",system_time->tm_year+1900);
sprintf(strmonth,"%d",system_time->tm_mon+1);
sprintf(strday,"%d",system_time->tm_mday);
sprintf(strhour,"%d",system_time->tm_hour);
sprintf(strminute,"%d",system_time->tm_min);
sprintf(strsecond,"%d",system_time->tm_sec);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -