Hi,
I have a 2 dimensional array. I know the size of the second dimension but not the first one i.e. number of columns is known but the number of rows is not known. In such situation, I can declare the array like this:
and assign to it the values like this:
Code:
int array[][4] = {
{11, 2, 3, 0},
{2, 4, 5, 0},
{4, 0, 0, 0},
{5, 0, 0, 0},
{3, 6, 22, 0},
{6, 0, 0, 0},
{22, 0, 0, 0}
};
My question is, if I need to copy the content of the above array into another array. How do I do this, i.e. the bytes to copy.
Let us say, I have:
Code:
int dest_array[][4];
memcpy(dest_array, array, (?) * 4 * sizeof(int));
How do I handle this. Should I keep track of number of rows, can I specify a safe big number i.e. 20 (instead of 7 as in the above example) and hope that the array is copied safely ?
Thanks,