用结构体表示日期,输入一个日期(年、月、日),计算从输入年的1月1日到输入的日期的总天数days并输出。
2条回答 默认 最新
漂泊者011 2014-12-22 05:54关注struct tm when; __time64_t now, result; int days; char buff[80]; time( &now ); _localtime64_s( &when, &now ); asctime_s( buff, sizeof(buff), &when ); printf( "Current time is %s\n", buff ); days = 20; when.tm_mday = when.tm_mday + days; result=mktime( &when ) ; double d=difftime(result,now); int nDays=d/60/60/24; 可以计算出结果差20天本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报