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

p int pointer

and assuming int on system 32-bit, 2 expressions produce same result.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -