#include <stdio.h> #include <time.h> int main() { enum Week { sun,mon,tue,wed,thu,fri,sat }; enum Week today; struct tm *p; time_t t; time(&t); p=localtime(&t); today=(enum Week)p->tm_wday;//必须强制类型转换 switch(today) { case mon: case tue: case wed: case thu: case fri: printf("工作日\n"); break; case sat: case sun: printf("休息日\n"); default: printf("Error\n"); } return 0; }
解决办法:
today=(enum Week)p->tm_wday;//必须强制类型转换