# include <stdio.h>
enum WeekDay //定义了一个数据类型(值只能写一下值)
{
MonDay, TuesDay, WednesDay, ThursDay, FirDay, SaturDay, SunDay
};
int main(void){
enum WeekDay day = WednesDay;
printf("%d
", day);
return 0;
}
输出结果:2
把一个事物所有可能一一列举出来
枚举的优缺点
优点:代码更安全
缺点:书写麻烦