I wanted to copy the contents of a c array to that of another, and I realized that you cant simply do
array1 = array2;
instead, you should either use a for loop to iterate over every index, or memcpy. I wanted to use memcpy as people said it would save space and I have a 3KB limit for my program (I want to fit it in a QR code).
I have a function where in my program where I have tried to utilize this, but when I print the results they come out as pointers. I am very confused as to why this is happening, because other people I've seen use this it turns out fine. What could i do instead? My function is here:
void ShiftBlock(int curBlock[4][2], int shiftCoords[2], int curGrid[WIDTH][HEIGHT])
{
int blockCoords[4][2] = {0};
memcpy(blockCoords, curBlock, sizeof(blockCoords));
for(int i = 0; i < 4; i++)
{
blockCoords[i][0] += shiftCoords[0];
blockCoords[i][1] += shiftCoords[1];
if (0 > blockCoords[i][0] || blockCoords[i][0] > WIDTH || 0 > blockCoords[i][1] || blockCoords[i][1] > HEIGHT || curGrid[blockCoords[i][0]][blockCoords[i][1]] != 0)
{
return;
}
}
memcpy(curBlock, blockCoords, sizeof(curBlock));
}