初学者,单链表的问题,求指导
#include<stdio.h>#include<stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
}len;
void creat()
{
len *head,*p,*s;
int i, number;
if ((head = (len*)malloc(sizeof(len))) == NULL)
{
printf("error");
exit(0);
}
printf("please input 5 numbers:");
p = head;
for (i = 0; i < 4; i++)
{
p = (len*)malloc(sizeof(len));
s = (len*)malloc(sizeof(len));
scanf_s("%d", &number);
p->data = number;
p = p->next;
printf("The value is:%d",p->data);
}
s->next = NULL;
}
void main()
{
creat();
}
不知道错在哪里,谢谢