#include <stdio.h>
//给枚举类型限定字节数,只能在C++11模式下运行
typedef enum weekday: unsigned char {
SUN, MON, TUE, WED, THU, FRI, SAT
} weekday_t;
int main() {
weekday_t weekday = MON;
printf("%d\n", sizeof (weekday_t));
printf("%d\n", sizeof (weekday));
return 0;
}
enum类型的变量定义为一个字节存储
最新推荐文章于 2024-07-01 12:00:10 发布