I'm struggling to get my head around what is being instantiated here with (*image)
(and what to do with it) in this line:
RGBTRIPLE(*image)[width] = calloc(height, width * sizeof(RGBTRIPLE));
I understand what is being assigned - a chunk of memory as an array of RGBTRIPLE
s of width width*sizeof(RGBTRIPLE)
, but what is (*image)
doing and how do I use it? I think it's a pointer to the array; in which case am I using it correctly when I pass it to further functions:
void avg(RGBTRIPLE image[])
{
printf("b image: %p\n", image);
}
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
printf("a image: %p\n", image);
avg(*image); // defereference image
return;
}
>> a image: 0x7f4450729010
>> b image: 0x7f4450729010
Is this the correct way to use *image
(I was to pass a reference to the original image
array to my function avg()
, not a copy of the array)?