What value does an enumeration object have if it is set to a value not equal to any of its respective enumeration constants?
Consider the following code:
enum foobar{
FOO = 1,
BAR = 5
};
enum foobar baz = 5;
enum foobar qux = 42;
The variable baz
is set to the integer value 5
, while the variable qux
is set to the integer value 42
.
I suspect the variable baz
will hold the value BAR
, but I'm unsure about the variable qux
. No enumeration constant was assigned the value 42
, so what happens when an enum foobar
variable is set to such a value?
Is the C99 standard explicit about the outcome?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…