This is similar to a question that had to be answered already somewhere, but I can not find something satisfactory. In any case, I need to return something similar from the function:
{ {"foo", "bar"}, {"baz", "foo"}, {"foo", "bar"} }
I am familiar with using argv , and I understand what its types mean, but for some reason I can't get the type of the above expression correctly. There will always be 2 string literals in the innermost part, and so I thought something like
char **s[2] or char *(*s[2])
should be what I do, but for some reason I always get segfault no matter what permutation I try when I try to iterate and use printf . Also, the compiler constantly complains about incompatible types of pointers, extra elements and too many braces. This is the current code:
char *(*s[2]) = { {"foo", "bar"}, {"baz", "spam"}, {"eggs", "ham"} };
source share