2013-01-15 85 views
0

我認爲它會容易得多,但我不能在簡單的mql4函數中使用二維數組作爲參數並在其中插入元素。我不知道問題出在哪裏。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); 

... 

} 

該錯誤消息我得到的是「1個參數ArrayCopy功能必須陣」 ......但是,它是...難道不是嗎?

有人知道該怎麼做嗎?

在此先感謝。

PD:在執行時,沒有編制

回答

0

,當我試圖測試功能與以下簽名並將其編譯我認爲它會工作,它失敗了,那麼。試試看:

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

int somenumber[5][5]; 
somenumber[0][0]=7; 
foo (somenumber); 
+0

我會粘貼我的代碼,也許我的問題不夠寬,對不起。給我5分鐘來編輯它。 –

+0

我意識到這個問題與ArrayCopy函數更相關,所以不要編輯這個問題,我會接受你的答案,因爲你的答案是邏輯的,並且在新問題中詢問數組的副本。 –