N
noridotjabi
Why is it not possible to return char** from a funcion. For example:
char** foo(void) {
char[][] foobar = {"foo", "bar"};
return foobar;
}
int main(void) {
printf("%s\n", foo()[0]);
return 0;
}
I have no idea why this does not work. Maybe I am doing something
wrong? This is not the actual code that I am comping but I didn't want
to post that as the relevant code is 200 lines long. I get warnings
when I try to compile this and a segmentation fault upon function call.
Thanks.
Nori
P.S. Is there anyway to get rid of that pesky "function returns adress
of local variable" warning?
char** foo(void) {
char[][] foobar = {"foo", "bar"};
return foobar;
}
int main(void) {
printf("%s\n", foo()[0]);
return 0;
}
I have no idea why this does not work. Maybe I am doing something
wrong? This is not the actual code that I am comping but I didn't want
to post that as the relevant code is 200 lines long. I get warnings
when I try to compile this and a segmentation fault upon function call.
Thanks.
Nori
P.S. Is there anyway to get rid of that pesky "function returns adress
of local variable" warning?