Subtle differences in C pointer addresses -
what difference between:
*((uint32_t*)(p) + 4); *(uint32_t*)(p+4); or there difference in value?
my intuition in later example value starts @ 4th index of array p pointing @ , takes first 4 bytes starting index 4. while in first example takes 1 byte every 4 indices. intuition correct?
the p+4 expression computes address adding 4*sizeof(*p) bytes value of p. if size of *p same of uint32_t, there no difference between results of these 2 expressions.
given that
pintpointer
and assuming int on system 32-bit, 2 expressions produce same result.
Comments
Post a Comment