I
InuY4sha
Hi list,
I've got the following stuff
struct mystruct {
const char *first;
const char *second;
const int val;
};
static const struct mystruct data[] = {
{ "hello", "world", 4 },
{ "hello", "friend", 5 }
};
void myfunc(int myvar){
switch(myvar)
{
case(data[0].val): ///ERROR!
{
printf("%s",data[0].first);
break;
}
default:
{
break;
}
}
}
and it gives me this error: "case label does not reduce to an integer
constant" with reference to the line marked with the "ERROR!" comment.
I was wondering why it complained considering that, according to the
definition, that IS a constant..
I can use an if statement I know .. but I seek knowledge not
workarounds
I've got the following stuff
struct mystruct {
const char *first;
const char *second;
const int val;
};
static const struct mystruct data[] = {
{ "hello", "world", 4 },
{ "hello", "friend", 5 }
};
void myfunc(int myvar){
switch(myvar)
{
case(data[0].val): ///ERROR!
{
printf("%s",data[0].first);
break;
}
default:
{
break;
}
}
}
and it gives me this error: "case label does not reduce to an integer
constant" with reference to the line marked with the "ERROR!" comment.
I was wondering why it complained considering that, according to the
definition, that IS a constant..
I can use an if statement I know .. but I seek knowledge not
workarounds