I'm trying to pass a two-dimensional array to a function. The function is defined as:
long foobar(char foo[][CONST]);
I have to create that array dynamically. Currently I do that this way:
char* bar = newchar[count * CONST];
But when I'm trying to pass the array I get a type conversion error. I tried a lot of different ways to pass the pointer and/or to allocate the memory, but apparently I didn't find the right way or combination of definition, allocation, casting and calling.
Unfortunately, I cannot change the definition of the function, which (IMHO) is pretty stupid. :(
Multidimensional arrays are difficult to mess with. But the important fact is that any MD array is actually just a 1D array with special syntax to access it. Use this fact to create and cast. Oh, and don't forget to pass the size of the first dimension as argument to your function: