I've been trying to pass a multidimensional array, of an unknown size, to a function, and so far have had no luck, when the array is declared, its dimensions are variables:
double a[b][b];
As far as I can tell, I need to give the value of b when I declare the function, a can be unknown. I tried declaring b as a global variable, but it then says that it must be a constant.
ie:
int b;
double myfunction(array[][b])
{
}
int main()
{
int a;
double c;
double myarray[a][b];
c=myfunction(myarray);
return 0;
}
Is there any way get this to work?
std::vectormakes life so much easier.std::vectororboost::multiarray.doublein front of your array parameter. I don't know if this is an oversight in your post here or if it is missing from the code you are compiling as well.std::vectormakes life easier for single-dimension arrays but it complicates multi-dimension arrays since the size of each row must be set separately.