谁能解释一下?
struct node
{
int data;
struct node * link;
}
main()
{
struct node *p, *list, *temp;
list = p = temp = NULL;
.........................
.........................
}
addbeg()
{
int x;
temp=malloc(sizeof(struct node));
scanf("%d", &x);
temp->data=x;
temp->link = list;
list=temp;
}
这是一段通过C语言在链表中输入数据的代码。代码不完整,但我认为它足以达到目的。请基本上解释以下几行的编码:
temp=malloc(sizeof(struct node));
和
temp->link = list;
list=temp;.