Suppose I define two arrays, each of which has 2 elements (for theoretical purposes):
char const *arr1[] = { "i", "j" };
char const *arr2[] = { "m", "n" };
Is there a way to define a multidimensional array containing these two arrays as elements? I was thinking of something like the following, but my compiler displays warnings about incompatible types:
char const *combine[][2] = { arr1, arr2 };
The only way to compile is for the compiler to treat arrays as pointers:
char const *const *combine[] = { arr1, arr2 };
Is this really the only way to do this, or can I somehow save the type (in C ++, information like the runtime will know that it is an array) and consider it combineas a multidimensional array? I understand that this works because the array name is a const pointer, but I'm just wondering if there is a way to do what I ask in standard C / C ++, rather than relying on compiler extensions. Maybe I'm too used to Python lists, where I could just throw something into them ...
source
share