RGBTRIPLE (*image)[width] = calloc(height, width * sizeof(RGBTRIPLE))
I don't fully understand the code. What I understand is that:
calloc(height, width * sizeof(RGBTRIPLE))
- we are organizing a place somewhere in heap memory of a certain size for certain data and set all values in this memory to0
RGBTRIPLE (*image)[width]
means variable image is a pointer to an array of length width of RGBTRIPLE.RGBTRIPLE
is a data structure that contains 3 variables:BYTE rgbtBlue
;BYTE rgbtGreen
;BYTE rgbtRed
;
Why arrey is not created for two values: width
and length
but only for width
. For me, this code shows that we have created only arrey [1d] and not as it should be [2d], that the image is 2d...
Below I am sending a drawing that I made for my reasoning.
trying to understand lines of code from pset CS50 smiley.