I'm trying to make a multidimensional array, which contains lots of data.
However, I don't know the initializer size of the middle array since this is always different for each array level.
It looks like this:
char* spawnableVehicles[3][][3] = {
{
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
},
{
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
},
{
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
{"test1", "test2", "test3"},
},
}
How do I initialize the size of the middle array?
spawnableVehicles[0]cannot be an array of five things whilespawnableVehicles[1]is an array of three things.) You must either specify a maximum size for the middle dimension that encompasses all cases, or you must use a different data structure.char* spawnableVehicles[3][8][3]... or stop using your array approach and switch to pointers withmalloc()andfree().malloc.