1
If there is no negative value in the enumeration variable, for example
Enumeration type
test
{
One,
b,
};
With this definition, the system will treat enumerated variables as unsigned integers, that is, unsigned.
Internationalorganizations (same as international organizations)
Type. Just use %u format when outputting.
Enumeration type
test
t
=
a;
printf("%u ",
t);
2
If there is a negative value in the enumeration variable, the system will be treated as an integer, that is, an int type. By definition
Enumeration type
test
{
a=- 199,
b,
};
When outputting, you need to use %d format:
Enumeration type
test
t
=
a;
printf("%d ",
t);
three
Because enumeration variables are generally not too large when they are written, it is rare that there are no negative numbers, that is, when they are treated as unsigned numbers, they are beyond the range of positive numbers that can be represented by signed numbers, that is, the highest bit is generally not set to 1, so it is no problem to output with% d in most cases.