Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to explain this program in C language?
How to explain this program in C language?
p+0x 1 = 0x 1000 14

P is the first address of a structure, so p+ 1 is the address pointing to the next structure, and the memory occupied by a structure is sizeof(struct Test)=20.

(unsigned long integer) p+0x1= 0x100001

The value of p is the address value 0x 100000. (unsigned long integer) p converts p into an unsigned long integer value, which is 0x 1 00001after adding1.

(unsigned int *) p+0x1= 0x100004

The value of p is an address value of 0x 100000. (unsigned int*) p converts p into an unsigned long pointer, while in c/c++ language, a long pointer takes up 4 memories, so its value is 0x 100004.