#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
int data;
struct Node *next;
}No;
int main()
{
No *head; //头指针
int array[10]={0,1,2,3,4,5,6,7,8,9};
head=(No*)malloc(sizeof(No));
No *p=head;
int i=0;
for(;i<10;i++)
{ //创建下一个节点时,要先为该节点分配存储空间,然后才能用上一个节点指向下一个节点
head->data=array[i];
head->next=(No*)malloc(sizeof(No));
head=head->next;
}
head->next=NULL; //尾指针为空
while(p->next!=NULL)
{
printf("%d",p->data);
p=p->next;
}
return 1;
}