#include <stdio.h>
enum color{red,yellow,green};
int main()
{
int t;
t=green;
printf(" %d\n",t);
printf(" %d\n",t-1);
printf(" %d\n",t-2);
return 0;
}
enum 枚举类型名字{0,1,2,...};
0,1,2,…表示下标
#include <stdio.h>
enum color{red,yellow,green};
void f(enum color c);
int main()
{
enum color t=green;//t为enum color 的变量类型
printf("%d\n",t);
scanf("%d",&t);
f(t);
return 0;
}
void f(enum color c)//enum不能忘
{
printf("%d\n",c-1);
}
版权声明:本文为DYW929076863原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。