J
John Goche
Hello,
The following program compiler and runs fine under gcc and produces
the output 3. However, I am not sure whether such behavior is legal.
In particular, as a related question, how would I go about checking
that a supplied integer is contained within the set of values of an
enumeration? Is there a way to do this?
Thanks,
JG
#include <stdio.h>
int main() {
enum { A = 1, B = 2 } foo;
foo = 3;
printf("%d\n", foo);
}
output: 3
The following program compiler and runs fine under gcc and produces
the output 3. However, I am not sure whether such behavior is legal.
In particular, as a related question, how would I go about checking
that a supplied integer is contained within the set of values of an
enumeration? Is there a way to do this?
Thanks,
JG
#include <stdio.h>
int main() {
enum { A = 1, B = 2 } foo;
foo = 3;
printf("%d\n", foo);
}
output: 3