user-0 提问: 取消对NULL指针的引用怎么解决？？？

回复:
user: user-0
content: 试了一下，成功了，感谢

user: user-1
content: 修改如下，供参考：#include"stdio.h" #include"malloc.h" typedef char ElemType; typedef struct Node {         ElemType data;         struct Node* next; }LinkNode;  void CreateList(LinkNode** L, ElemType a[], int n)//头插法建立单链表 {         LinkNode* s,*p;         int i;         *L = (LinkNode*)malloc(sizeof(LinkNode));         (*L)->next = NULL;  //L->next = 0;         p = *L;         for (i = 0; i < n; i++)         {                  s = (LinkNode*)malloc(sizeof(LinkNode));                  s->data = a[i];                  s->next = p->next;                  p->next = s;         } } void InitList(LinkNode **L)//初始化 {         *L = (LinkNode*)malloc(sizeof(LinkNode));         (*L)->next = NULL; //L->next = 0; } ElemType Get(LinkNode* L, int i) //查找第i个结点的值 {         int j = 0;         LinkNode* p = L;         while (j < i && p!= NULL)         {                  p = p->next;                  j++;         }         if (i == j)                  return p->data;         else                  return 0; } int Locate(LinkNode* L, ElemType key)//查找结点值等于key的结点 {         LinkNode* p;         int i = 1;         p = L->next;         while (p)//(p != 0)         {                  if (p->data != key)                      p = p->next;                  else                      break;                  i++;         }         return i; } int Insert(LinkNode** L, int i, ElemType x)//插入 {         LinkNode* p = *L, * s;         int j = 0;         if (i <= 0)                  return 0;         while (j < i - 1 && p != NULL)         {                  p = p->next;                  j++;         }         if(p==NULL)//if (p == 0)                  return 0;         else         {                  s = (LinkNode*)malloc(sizeof(LinkNode));                  s->data = x;                  s->next = p->next;                  p->next = s;                  return 1;         } } int Delete(LinkNode* L, int i, ElemType e)//删除 {         LinkNode* p = L, * q;         int j = 0;         while (j < i - 1 && p != 0)         {                  p = p->next;                  j++;         }         if (p == NULL) //(p == 0)                  return 0;         else         {                  q = p->next;                  if (q == NULL)  //(q == 0)                          return 0;                  e = q->data;                  p->next = q->next;                  free(q);                  return 1;         } } void Disp(LinkNode* L)//输出单链表 {         LinkNode* p = L->next;         while (p)  //(p != 0)         {                  printf(" %c ", p->data);                  p = p->next;         }         printf("\n"); } int main() {         int x = 1;         LinkNode* h, a;         ElemType e = 1;         h = &a;         printf("单链表基本运算如下: \n");         printf("  (1)初始化\n");         InitList(&h);          printf("  (2)插入元素a,b,c,d\n");         Insert(&h, 1, 'a');         Insert(&h, 2, 'b');         Insert(&h, 3, 'c');         Insert(&h, 4, 'd');         printf("  (3)输出链表: ");         Disp(h);          printf("  (4)定位\n");         printf("    定位第%d个结点的值为：%c\n",2,Get(h, 2));                  printf("  (5)查找\n");         printf("    查找%c的结点位置：%d\n",'c',Locate(h, 'c'));           printf("  (6)插入\n");         Insert(&h, 4, 'x');         Disp(h);          printf("  (7)删除\n");         Delete(h, 3, e);         Disp(h);                   return 0; }

user: user-0
content: 引用 1 楼 user-2的回复:及时让它别NULL。 那怎么改呢？

user: user-2
content: 及时让它别NULL。