a.cpp:
static const struct A {
int a1;
const char ** a2;
} as[] = {
{1,(const char *[]){"LOL",NULL}},
{2,(const char *[]){"LOL","LOL2",NULL}}
};
const char ** getA(int a) {
int i = 0;
for(;i< sizeof(as)/sizeof(struct A);i++){
if (as[i].a1 == a)
return as[i].a2;
}
}
Is there a context or scope problem in returning const char ** from a static const struct initialized statically?
There's certainly no scope problem. Scope pertains to variables, not to values. (There is a problem with missing { in your code, though.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With