I have a character pointer named label, and also an enumerator that contains an element named “label”. How can I differentiate between them in a case statement?
switch((I_ARG_TYPES) progrm[i].arg[j].type){
case (I_ARG_TYPES) value:
break;
case (I_ARG_TYPES) label:
break;
default:
break;
}
Global scope:
typedef enum I_ARG_TYPES {
value, label
} I_ARG_TYPES;
In the same function as the switch:
char label[MAXLINELENGTH]
“Case label does not reduce to an int” on the case for label.
You can’t. (Similarly, if you do
float printf, you can’t call theprintf()function in that scope.)Solution: Don’t give your local variables the same name as things from the global scope.