用c++程序编写 输入年月日,输出距今天还有多少天,星期几,是否是公历节日。

用c++程序编写 输入年月日,输出距今天还有多少天,星期几,是否是公历节日。

获取今天时间是一个依赖平台的函数,所以需要知道平台

这个怎么一直报错啊

这是获取时间结构体就能完成你的要求。一般是获取出来的是阳历,距离还有多少天自己算就行

#include"stdio.h"
#include<time.h>

int main()
{
    struct tm *loca_t;
    time_t ti;
    ti = time(NULL);
    loca_t = localtime(&ti);
    printf("Year=%d\n",loca_t->tm_year+1900);
    printf("Mon=%d\n",loca_t->tm_mon+1);
    printf("Day=%d\n",loca_t->tm_mday);
    printf("weekday=%d\n",loca_t->tm_wday+1);
}