Can ArrayCopy function work for 2 dimensional array too ?

 

Hello fellow coders

Can ArrayCopy function be used for 2 dimensional array too ?

The code below does not provide me any error on Meta Editor and compiling wise, it was fine. However, just curious if the ArrayCopy function is meant to be used for 2 dimensional array too.

ArrayCopy(array1, array2, 0, 0, WHOLE_ARRAY);


Sharing your thought will be really appreciated.

Kind regards.

 

Hi FE

Somewhere in the back of my mind I remember reading that it only copies the first dimension but I could be wrong. Should be fairly easy to test it in a debug....? If not, a nested loop should do the trick. I'd be interested to hear your results.

 
Filter:

Hi FE

Somewhere in the back of my mind I remember reading that it only copies the first dimension but I could be wrong. Should be fairly easy to test it in a debug....? If not, a nested loop should do the trick. I'd be interested to hear your results.


Just testing now. So I will know the results quite soon. :)

 

I did not throughly tested ArrayCopy yet. However I did remember that the results did look seemingly wrong when I use ArrayCopy for 2d array. So I just replace ArrayCopy to this code below for safety.

    for(int i = 0; i < m; i++)
        for(int j = 0; j < n; j++)
            newmatrix[i][j] = oldmatrix[i][j];
    
 
Thanks for the update mate
 
Filter:
Thanks for the update mate
No prob.  :)