Passing multi-dimensional arrays to functions

Apologies if this has been answered, but my scouring of the internet has not been able to solve my problems so far. Essentially, I want to pass a 2-D array to a function to get a number out:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
double apd(double **m, int percent, int t_startPos, int volt, int size);
int main()
{
	int size_full = 20000;        int nvar = 15;
	double stepsize = control_full[1][0] - control_full[0][0];
	int size = bcl/stepsize;
	double control[size][nvar];
	double apd90_cont = apd(&&control, 90, t_startPosControl, volt, size);
}

double apd(double **m, int percent, int t_startPos, int volt, int size)
{
	double ap;
	// Use the inputs to get the double ap
	return (ap);
}


When I try and run compile this using g++, I get the error message:
param_compare20101011.cpp:125: error: invalid conversion from ‘void*’ to ‘double**’
param_compare20101011.cpp:125: error: initializing argument 1 of ‘double apd(double**, int, int, int, int)’
param_compare20101011.cpp:125: error: label ‘control’ used but not defined
(where the line 125 is the line for the call to the function in the actual program).

I've tried a couple of different configurations, but to no avail. Can anyone help?

Thanks.
Read this: http://cplusplus.com/forum/articles/17108/
Especially this part MD Array Flavor 1: Straight

BTW, you can't allocate variable size arrays on the stack. This line double control[size][nvar]; shouldn't compile. If it does, then it is a non-standard extension for your compiler, try avoiding it, or you will have a lot of trouble porting your code to a different compiler (or even compiler version).
Topic archived. No new replies allowed.