看注释
#include
#include
#define NULL 0;
struct numb
{
int data;
struct numb *next;
};
struct numb *create()
{
struct numb *head,*s,*p;
int i;
head=s=p=NULL;
p=(struct numb *)malloc(sizeof(struct numb));
printf("please input 10 numbers\n");
for(i=0;i<10;i++)
{
s=(struct numb *)malloc(sizeof(struct numb));
p->next=s;
if(i==0) // 比较应该用两个=
head=p;
printf("%d\n",i);
scanf("%d",&p->data);
p=p->next;
if(i==9) // 比较应该用两个=
p->next=NULL;
}
return (head);
}
void print(struct numb *head)
{
struct numb *current;
int i;
printf("records are :\n");
current=head;
for(i=0;i<10;i++)
{
printf("%3d",*current);
current=current->next;
}
}
void main()
{
struct numb *pHead,*p;
pHead=create();
print(pHead);
getchar();
}