In this post, we will see how to resolve incrementing unsigned char *image
Question:
Best Answer:
From the code it is evident that the pointer points to an element of an array ofunsigned char
:image[i]
is equivalent (really equivalent, that is how it is defined) to *(image + i)
, ie it increments the pointer by i
and dereferences it. You can write image[0]
to get the element image
points to. You can type image[1]
to get the next element in the array.Lets call the actual array
x
then you can access its elements via incrementing image
like this:offset
in the outer loop which increments by 3 in each iteration and then instead of image[ i ]
they would have used image[ i + offset ]
. Instead they choose to increment image
which has the same effect.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review