#include<stdio.h>
struct node
{
int item;
struct node *link
};
main()
{
struct node *start,*list;
int i;
start = (struct node *)malloc(sizeof(struct node));
list = start;
start->link = NULL;
for(i=0;i<10;i++)
{
list->item = i;
list->link = (struct node *)malloc(sizeof(struct node));
}
list->link = NULL;
while(start != NULL)
{
printf("%d\n",start->item);
start = start->link;
}
}
正如标题所示,我试图迭代地遍历链表,预期输出为 0 1 。. 9 观察到的输出是: 9 代码有什么问题?