1

Lets say I have the following pointer arrays:

const char* m1[5] = { "bla", "asdada", "sadasde", "wrskm", "adjsad" };
const char* m2[5] = { "xxx", "yyy", "zzz", "uuu", "vvv" };
const char* m3[5] = { "lkkl", "kkk", "lkkl", "skl", "jkljkl" };
const char *m4[5] = { "one", "two", "three", "four", "five" };

I just want to represent the data above in a single array where each element represents one of the array above. like array of array of pointers to cons char structure(corrected me please if this saying wrong) I try to do the following but it doesn't work

char *(const char* exm[5])[4] = { &m1, &m2, &m3, &m4};

Help?

1 Answer 1

2

Remember that arrays naturally decays to pointers to their first element. For an array of pointers, that becomes a pointer to a pointer, i.e. const char ** for your arrays m1 to m4.

So you need an array of pointer to pointers:

const char **exm[] = { m1, m2, m3, m4 };
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.