计算2001年7月4日是星期几。
#include<stdio.h>
#include<time.h>
static const char *const wday[] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "-unknown-"
};
struct tm time_str;
tume_str.tm_year = 2001 - 1900; //years since 1900
time_str.tm_mon = 7 - 1;
time_str.tm_mday = 4;
time_str.tm_hour = 0;
time_str.tm_min = 0;
time_str.tm_sec = 1;
time_str.tm_isdst = -1;
if (mktime(&time_str) == -1)
time_str.tm_wday = 7;
printf("%s\n", wday[time_str.tm_wday]);