MQL4 - Multidimensional Array as Parameter in Function where is inserted a one-dimensional array

StackOverflow https://stackoverflow.com/questions/14330694

  •  15-01-2022
  •  | 
  •  

Question

I supposed it would be much easier, but I cant use a two-dimensional array as parameter in a simple mql4 function and insert elements in it. I don't know where the problem is.

I have a function declared like this:

void insert_array_in_multi(double simple_array[], double &multi_array[][]){

...
ArrayResize(multi_array,1);

ArrayCopy(multi_array[x][0],simple_array); // Here I want to copy the one-dimension array into the multidimensional one, in "x" position. And here is where I get the ERROR when executing.

// I use "multi_array[x][0]" because is the way I don't get errors when compiling; if I use  "multi_array[x]", meaning I want the one-dim array to be copied in the x pos of the multi-dim array, I get the error message "wrong dimension"

...
}





The other function calling this one, is like:

double bidiarray[0][10];

... as I put new elements, I resize the array to an array with 10 or more (primary) elements

... create a one-dimensional array like this:

double simple_array[10] = ...

... and then call to the previous function:

insert_array_in_multi(simple_array,bidiarray);

...

}

The error message I get is "1 parameter for ArrayCopy function must be array"... But, it is... Isn't it?

Somebody knows how to do it?

Thanks in advance.

PD: It fails when executing, not when compiling

Était-ce utile?

La solution

I tried testing function with following signature and it compiles, so I think it will work. Give it a try:

int foo(int something[][])
{
   return (0);
}

int somenumber[5][5];
somenumber[0][0]=7;
foo (somenumber);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top