Archived

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

Copying an Array

This topic is 5750 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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