Referencing C struct without referencing a member -


typedef struct s {   int x;   int y; } s;  typedef struct t {   s s; }  t t = {0}; t *pointer_to_t = &t;   printf("end address %x", pointer_to_t->s); printf("beginning address %x", &(pointer_to_t->s)); 

based on testing, pointer_to_t->s address of end of structure s

pointer_to_t->s - &(pointer_to_t->s) = sizeof(s) 

what expected behaviour here? or coincidence?

the expected behaviour here can range printing garbage nasal demons, because behaviour undefined. %x specifier makes printf expect integer gets struct, possible. what's happening here print s.x, again may spawn one-way portal Петропа́вловск-Камча́тский.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -