#include <time.h>
#include <stdlib.h>
#include <string.h>
int main()
{
time_t timep,Tim
struct tm *p
time(&timep)
p = localtime(&timep)//此函数获得的tm结构体的时间,是已经进行过时区转化为本地时间
//p = gmtime(&timep)//把日期和时间转换为格林威治(GMT)时间的函数
int Year = 1900 + p->tm_year
int Month = 1 + p->tm_mon
int Day = p->tm_mday
int Hour = p->tm_hour
int Minute = p->tm_min
int Second = p->tm_sec
char year[20]
char month[20]
char day[20]
char hour[20]
char minute[20]
char second[20]
printf("hour=%d\n", Hour)
printf("minute=%d\n", Minute)
printf("second=%d\n", Second)
return 0
}
每编译一次就会显示这一刻的系统时间;这个程序我也不太懂,我学长讲了半天,数据结构都整出来了,也没把我整明白,我再研究研究;希望能帮到你吧;
#include<stdio.h>int main(){
int hour,minute,second
printf("请输入时间:")
scanf("%d:%d:%d",&hour,&minute,&second)
printf("Time:%02d:%02d:%02d\n",hour,minute,second)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)