25.枚举enum

#include <stdio.h>  //fopen函数的包
#include <stdlib.h> //exit()函数的包
#include <string.h>

//定义一个枚举类型(默认从0开始)
enum ctype1 { one = 6, two, three, four, five} apple;

int main()
{
/*
1.什么是枚举类型
    枚举类型就是用声明符号名称来表示整数常量(用a来代表1),这些符号常量(a)成为枚举符
2.枚举类型的作用
    提高代码可读性
*/

//定义一个枚举类型(默认从0开始)
enum ctype { a = 6, b, c, d, e};
//实例化枚举类型
enum ctype color;

color = 100;

//int a = 100;

printf("%d====%zd\n", color, sizeof(color) );

apple = five;

printf("%d\n", two);

return 0;
}

 

posted @ 2021-07-28 16:19  学而不思则罔!  阅读(38)  评论(0)    收藏  举报