Why do C enumeration constants need a name? Because this:
#include <stdio.h>
enum {NO, YES};
int main(void)
{
printf("%d\n", YES);
}
works just the same as this:
#include <stdio.h>
enum boolean {NO, YES};
int main(void)
{
printf("%d\n", YES);
}
If you want to create a type that is ‘of the enum’, such as:
The easier way to do this is with a typedef:
And then all you have to do is use boolean as the type: