As I understand memcpy takes from one memory location and copies it to another. Therefore it needs the address of both locations.
Now I want to copy a part of a large array B into a part of a large array C defined as a **:
So what replaces the question mark? I would have thought that C[slice] would work but neither that nor &C[slice] works nor does &C + slice*imagesize but I get a can't access memory at that line.
Code:
float *A, *B;
if ((A = (float *)calloc(reduced_image ,sizeof(float))) == NULL)
{
printf("no cys1 memory\n");
exit(0);
}
if ((B = (float *)calloc(slices*reduced_image,sizeof(float))) == NULL)
{
printf("no cys1 memory\n");
exit(0);
}
memcpy(B + slice*reduced_image, A, sizeof(float)* reduced_image);
Now I want to copy a part of a large array B into a part of a large array C defined as a **:
Code:
float *B, **C;
if ((B = (float *)calloc(slice* reduced_image ,sizeof(float))) == NULL)
{
printf("no cys1 memory\n");
exit(0);
}
C = calloc(slice, sizeof(float*));
for (i = 0; i < slice; i ++)
C[i] = calloc(imagesize,sizeof(float));
memcpy(?,B + slice*reduced_image, sizeof(float)* reduced_image);
So what replaces the question mark? I would have thought that C[slice] would work but neither that nor &C[slice] works nor does &C + slice*imagesize but I get a can't access memory at that line.