I have a 2D array of strings char* d2Array[valueA][valueB].
This works fine, I am able to fill it with strings and access them. There is an issue when passing it to a function. You need to specify the second size parameter (i.e. void aFunction(char* d2Array[][valueB]). However, this is a variable, so I can't just put in a number.
If this function is in the same file, then making valueB global and writing the function as above works. However I'm not sure if this is "proper"? Or is it just working by chance? Is this actually safe to do?
Also, the problem I have is I need to pass d2Array to a function in another file. Is my only choice to make this variable all files in my program? And how would I even do that? Or is there a better way to do this?
It means that your compiler supports variable length arrays. However it would be much better to declare the function like
void aFunction( size_t valueA, size_t valueB, char* d2Array[][valueB] );without using any global variable.
To call the function you need to pass two dimensions of an array and the array itself.