The intent here is for each array in foos to be allocated by the compiler, and then foos itself would be a 4-element array laid out flatly in memory with each element being the pointer to the first element of its allocated array. In other words, it's a very similar situation to:

Code:

const char *strs[4] = {
"hello",
"world",
"various",
"strings"
};

In this case, the compiler acts exactly as I described, it allocates various char buffers in memory and then strs is 4 consecutive items in memory with each pointing to the first element of its char buffer. Is there not a more general way to do this for any array similar to the syntax I've used above? It is important that the inner arrays are able to be of variable length, just as with a char* array.

Note that I am using the first element of the array to indicate how many elements will be in the array; I'm not asking for any type of bounds checking, only allocation in a manner similar to what is done for arrays of char*.

Thanks for the tip. It's helpful to know that if worst comes to worst, I can do it that way. The only qualms I have are

1. Some of the arrays may be up to 8 or so items long, while the majority will be 3 or less. This means that I'll be using almost twice as much memory as necessary.

2. This involves hand-editing the second value after foos, which could lead to future errors when editing the file. Now in my specific case, I'm actually generating the C code from Python code, so this is less of an issue.

All things considered, I'll probably just go this way, but I was curious if there was a more general-purpose way of defining an array of variable-length arrays in the same way that one can define an array of variable-length character buffers.