I'm creating "Ships" game. I generate mField which will be my template to fill enemy field with ships. To do that I want to copy mField into eField.
My mField is dynamic 2D array of structures "Field" and it's filled like this in my cpp file:
mField = new Field*[x+3];
for (int i = 0; i < x+3; ++i)
mField[i] = new Field[y+3];
And declared like this in my header file
Field **mField;
Now for copying I tried
memcpy(&eField, &mField, sizeof(&mField));
although now when I fill my mField with ships an I see in enemy field exact copy of mField there instead of it being clean field. That's how I'm passing my field to function that changes my field:
void Map::changeField(int x, int y, string ciag,Field **field) {
...
}
Did I make some mistake in my function that it changes both arrays or I'm copying arrays in a wrong way?