struct A //size 4
struct B //size 8
unsigned char *mem;
A *a=(A *)mem;
B *b=(B *)a+sizeof(A); //I want address of b to be 4
Please correct me if I'm wrong:
lets say address of mem
is 0
, if so
address of a
is 0
, if so
address of b
is 0+8*4 //0+sizeof(A)*sizeof(B)
If that's correct How I cast 'pointer to struct A' to 'pointer to struct B' then add to the address a number. (commented in the code)
Thanks.