在学数据结构链式存储的时候遇到一点问题。
程序代码:
#include <stdio.h>
#include <malloc.h>
typedef int ElemType;
typedef struct Node
{
ElemType data;
struct Node *next;
} Node;
typedef struct Node *Linklist;
Linklist Create(Linklist head);
int main(void)
{
Linklist head;
Create(head);
printf("--------------");
while (head->next != NULL)
printf("%d.\n", head->data);
return 0;
}
Linklist Create(Linklist head)
{
int x, i = 1;
Linklist p, q;
q = head;
printf("Your %d input:(0 to quit)\n", i);
scanf("%d", &x);
while (x != 0)
{
p = (Node *)malloc(sizeof(Node));
p->data = x;
p->next = NULL;
q->next = p;
q = p;
scanf("%d", &x);
}
return head;
}
以上是我的代码,每当我输入数据的时候,程序就自动停止了。我到底是什么地方出错了?
还有 typedef struct Node * Linklist
Linklist p 声明的是一个指向Node的指针吗
那Linklist *p 又是什么意思呢?指向指针的指针?




