C语言 比较日期大小

#include 
#include 

int cmptime(int year, int month, int day)
{
	time_t now_time = 0, set_time = 0;
	struct tm p;
	p.tm_year = year-1900;
	p.tm_mon = month-1;
	p.tm_mday = day;
	p.tm_hour = 0;
	p.tm_min = 0;
	p.tm_sec = 0;
	p.tm_isdst = 0;
	set_time = mktime(&p);
	time(&now_time);
	return now_time - set_time;
}

int main()
{
	if(cmptime(2010, 10, 1)>0)
	{
		puts("当前日期大于2010年10月1日");
	}
	return 0;
}

你可能感兴趣的:(Windows编程)