下面的程序给出的输出4.我认为它会输出8的sizeof(int)的+的sizeof(无符号整数)这个结构的大小是多少?为什么?
#include<stdio.h>
#include<stdlib.h>
int main()
{
struct node
{
int a;
struct node * next;
};
struct node * p= (struct node *) malloc(sizeof(struct node));
printf("%d", sizeof(p));
}
你以指针的大小,而不是对象本身。 – Mysticial
同样重要的是要知道,如果你这个编译为32位或64位,作为有差别来了'int'和指针有多大。 – Raceimaztion