?? 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 + -