这么改下,看得更清楚点,供参考:
#include <stdio.h>
#include <stdlib.h>
struct Linkedlist{
int value;
struct Linkedlist* next;
};
int main()
{
int num[10] = {1,2,3,4,5,6,7,8,9,10};
struct Linkedlist head0 = {num[0],NULL}; //定义第一个结点
struct Linkedlist *temp= &head0; //定义结构体指针temp ,指向第一个结点
struct Linkedlist head1 = {num[1],NULL}; //定义第二个结点
temp->next = &head1;
temp = temp->next;
struct Linkedlist head2 = {num[2],NULL}; //定义第三个结点
temp->next = &head2;
temp = temp->next;
struct Linkedlist head3 = {num[3],NULL}; //定义第四个结点
temp->next = &head3;
temp = temp->next;
struct Linkedlist head4 = {num[4],NULL};
temp->next = &head4;
temp = temp->next;
struct Linkedlist head5 = {num[5],NULL};
temp->next = &head5;
temp = temp->next;
struct Linkedlist head6 = {num[6],NULL};
temp->next = &head6;
temp = temp->next;
struct Linkedlist head7 = {num[7],NULL};
temp->next = &head7;
temp = temp->next;
struct Linkedlist head8 = {num[8],NULL};
temp->next = &head8;
temp = temp->next;
struct Linkedlist head9 = {num[9],NULL};
temp->next = &head9;
for(temp = &head0;temp != NULL;temp = temp->next)
printf("%d\t",temp->value);
return 0;
}