Archived

This topic is now archived and is closed to further replies.

Teric

Copying an Array

Recommended Posts

Teric    204
In my code, I have two arrays with the same bounds, and I''m trying to copy one to the other.
int mBlockGrid[5][5];
int TempGrid[5][5];
.
.
(Code to initialize the TempGrid array)
.
.
//Copy the TempGrid array to the mBlockGrid array
&mBlockGrid = &TempGrid;
 
However, the compiler complains by saying "left operand must be l-value" I''m not sure what I''m doing wrong. Suggestions?

Share this post


Link to post
Share on other sites
GCoder    164
Hallo......=0)

What you''re doing (or trying to do) there, is like saying

"make this address equal to that address"....which you can''t do....so have a go with this :

//Copy the TempGrid array to the mBlockGrid array
memcpy(mBlockGrid, TempGrid, sizeof(TempGrid));

that should do it....

:o)

Share this post


Link to post
Share on other sites