枚举,一种不大常见的东西,一般用于需要多次用到连续的数例如0123但又懒得用多个const int,
这时候就可以用枚举 。
#include <stdio.h>
enum color {
red,blue,yellow,numbercolors
};
void p(enum color t);
int main() {
p(red);
}
void p(enum color t)
{
printf("red=%d\n",t);
printf("numbercolors=%d",numbercolors);
}
red=0
numbercolors=3
--------------------------------
Process exited after 0.06457 seconds with return value 0
请按任意键继续. . .