Tuesday, April 5, 2011

struct pointer + 1

Given

toto_t* p_toto = ...;

then

p_tata = (tata_t*)(p_toto + 1)

means that p_tata points sizeof(toto_t) further than p_toto.

p_tata = (tata_t*) p_toto + 1

means that p_tata points sizeof(tata_t) further than p_toto.