下面的程序給出的輸出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