c - 为什么 C 枚举常量需要一个名字?

标签 c

为什么 C 枚举常量需要一个名字?因为:

#include <stdio.h>

enum {NO, YES};

int main(void)
{
    printf("%d\n", YES);
}

工作原理与此相同:

#include <stdio.h>

enum boolean {NO, YES};

int main(void)
{
    printf("%d\n", YES);
}

最佳答案

这样就可以创建枚举类型的变量了:

enum boolean read_file = NO;

关于c - 为什么 C 枚举常量需要一个名字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1849895/

相关文章:

c - XCode - 导入 Sedna 库

c - .so : undefined reference to 'min'

c - C中的字符串操作

c - 在函数参数中弹出队列

c - linux函数获取挂载点

c - C 中指针前进并在 strchr 之后再获取 2 个字符

c - jemalloc 和 tcmalloc 如何跟踪线程?

c - 处理器如何知道断点?

c - 将字符串传递给 init 函数并将其存储在 malloc 结构中

c - udp 在同一个套接字上发送和接收