刚学链表,这是一个带头结点链表,能编译但是运行不了,是哪里写错了。
#include <stdio.h>
#include <stdlib.h>
#include <mem.h>
#define Null 0
typedef struct node
{
int date;
struct node* next;
}*point,Node;
int main()
{
int temp;
point H,p,pre;
H = (point)malloc(sizeof(Node));
printf("请输入数字");
scanf("%d",&temp);
while (temp != 0)
{
p = (point)malloc(sizeof(Node));
p->date = temp;
pre->next = p;
pre = p;
printf("请输入数字");
scanf("%d", &temp);
}
pre->next = Null;
p = H->next;
while (p != Null)
{
printf("%d", p->next);
p = p->next;
}
return 0;
}