Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Please consult the offset position of structural members in the structure.
Please consult the offset position of structural members in the structure.
Because you define t as a structure pointer, pointing to the starting address of 0.

After the sentence struct test _ s * t = NULL is executed, t->; The address of pad0 is 0x00000000. Because all members in the structure are int-type, t->; The address of pad 1 is 0x00000004, and so on t->; The address of pad9 is 0x00000020.

& This is the address operator. (t->; Pad9) means to take the address of t->pad9, then convert it into int type and output 32.

If t is not defined as NULL, the printed address is relative to sss, as shown in the following example.

int main(int argc,char *argv[])

{

Structural test _ s sss

Structural test = & ampsss

printf("%d\n ",(int)& amp; (t->; pad 2));

Returns 0;

}