发布网友 发布时间:2022-12-06 15:41
共1个回答
热心网友 时间:2023-09-16 05:10
#include <stdio.h>
#include <time.h>
int main()
{time_t timep;
struct tm *tp;
time(&timep);
int p;
tp = localtime(&timep); //取得系统时间
printf("Today is %d-%d-%d\n", (1900 + tp->tm_year), (1 + tp->tm_mon), tp->tm_mday);
printf("Now is %d:%02d:%02d\n", tp->tm_hour, tp->tm_min, tp->tm_sec);
p=tp->tm_sec;
printf("p=%d\n",p);
return 0;
}