-sharpinclude <stdio.h>
struct test{
int i;
short c;
char *p;
};
int main(void)
{
struct test *pt = NULL;
printf("%p\n", &(pt->i));
printf("%p\n", &(pt->c));
printf("%p\n", &(pt->p));
printf("%lu\n", sizeof(struct test));
return 0;
}
is compiled and output on
Windows 10x64, and it is found that size is 16 bytes
.PS C:\Users\salamander\Desktop> ./test
0000000000000000
0000000000000004
0000000000000008
16
Why did the starting position of p become 00000000000008?
guess that 2 bytes are added after short, which is 4 bytes, and the pointer itself should be 8 bytes