#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
struct s1 {
int a;
char *c;
};
void main()
{
char t='a';
struct s1 *u=malloc(sizeof(struct s1));
printf("size of s1: %d\n", sizeof(struct s1));
printf("%p,%p\n",u, u->c);
u->c=&t;
printf("%p,%p: %lx, %c\n",u, u->c, *((uint64_t *) ((char *)u + 8)), *(u->c));
printf("%p\n", &(u->c));
free(u);
return;
}
输出结果:
size of s1: 16
0x2018010,(nil)
0x2018010,0x7fff1060b0a7: 7fff1060b0a7, a
0x2018018