以下是如何定义 Weekday 类型以使枚举器值从1
开始:星期一到星期日的数字值将对应于值1
到7
。
#include <stdio.h>
int main(void) {
enum Weekday {Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
enum Weekday today = Wednesday;
printf("Weekday created/n");
printf("%d/n",today);
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266719.html