为什么链表不能输出????
#include<stdio.h>#include<stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
}Node, *LNode;
LNode In_link(LNode head);
void Display_link(LNode head);
void Free_link(LNode head);
int main()
{
LNode head = NULL, top = NULL;
head = In_link(head);
Display_link(head);
putchar(10);
top = In_link(top);
Display_link(top);
putchar(10);
Free_link(head);
Free_link(top);
return 0;
}
LNode In_link(LNode head)
{
int num;
Node *link = NULL, *incept_link = NULL;
printf("Please input the number:");
scanf("%d", &num);
while(num)
{
link = (Node *)malloc(sizeof(Node));
link->data = num;
if(head == NULL)
head = link;
else
incept_link->next = link;
incept_link = link;
scanf("&d", &num);
}
if(incept_link != NULL)
incept_link->next = NULL;
return head;
}
void Display_link(LNode head)
{
Node *incept_link = NULL;
if(head == NULL)
{
printf("The link is empty!\n");
return;
}
incept_link = head;
while(incept_link)
{
printf("%3d", incept_link->data);
incept_link = incept_link->next;
}
}
void Free_link(LNode head)
{
if(head == NULL)
{
printf("The link is empty!\n");
return;
}
if(head->next)
Free_link(head->next);
Free_link(head);
}