struct t{
char days[20];
int date;
char x;
struct t *next;
}*head
printf("%ld\n", sizeof(head));
Run Code Online (Sandbox Code Playgroud)
其中sizeof(*void)=8,sizeof(int)=4,sizeof(char)=1
为什么打印8?
head是一个指向struct的指针t,因为我假设你正在运行x64程序,所以它是8个字节.如果您想要基础类型的大小,请执行以下操作:
sizeof(*head)
Run Code Online (Sandbox Code Playgroud)