Let say I have a multi-dimensional array like
int a[10][10]
int b[10][10]
void arrayCopy(int* a, int* b, int size){
memcpy(b, a, size);
}
int main(){
a[0][0] = 13;
a[0][1] = 17;
"and so on..."
arraycopy(&a[0][0], &b[0][0], 10);
}
This code is not working I am unable to copy all the values from a -> b, where am I doing wrong??
The problem is in the size.
sizeof(a)is100*sizeof(int), and you should pass that number.(Your code copies
10 bytes, when you want to copy100 ints.