0

我认为这会容易得多,但我不能在简单的 mql4 函数中使用二维数组作为参数并在其中插入元素。我不知道问题出在哪里。

我有一个这样声明的函数:

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);

...

}

我得到的错误消息是“ArrayCopy 函数的 1 个参数必须是数组”......但是,它是......不是吗?

有人知道怎么做吗?

提前致谢。

PD:执行时失败,而不是编译时

4

1 回答 1

0

我尝试使用以下签名测试功能并编译,所以我认为它会起作用。试试看:

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

int somenumber[5][5];
somenumber[0][0]=7;
foo (somenumber);
于 2013-01-15T03:40:54.257 回答