#include<stdio.h>
enum color //枚举的关键字
{
red, yellow, blue, white, black
};
int main()
{
int i;
for ( i = red; i <= black; i++ )
{
printf("%d\n",i);
}
return 0;
}
那只能告诉你这样做不行,如果非要这样,下面是个可行的方法
#include<stdio.h>
enum color //枚举的关键字
{ red, yellow, blue, white, black
};
int main()
{ int i; char *a[5]={"red","yellow","blue","white","black"}; for ( i = red; i <= black; i++ ) { printf("%s\n",a[i]); } return 0;
}