I have two arrays of chars, allocated as follows:
unsigned char *arr1 = (unsigned char *)malloc((1024*1024) * sizeof(char));
unsigned char *arr2 = (unsigned char *)malloc((768*768) * sizeof(char));
I would like to copy arr2 into arr1, but preserve the row/column structure. This means that only the first 768 bytes of each of the first 768 rows will be changed in arr1.
I wrote a for loop for this, but it's not fast enough for my needs.
for (int x = 0; x < 768; x++) //copy each row
{
memcpy(arr1+(1024*x),arr2+(768*x), nc);
}
Is there a better solution?
Thanks!