user-0 提问: 为什么我的单链表只能打印第一个位置的，后面调用的不显示？？

回复:
user: user-1
content: C和C++完整教程:https://blog.csdn.net/it_xiangqiang/category_10581430.html C和C++算法完整教程:https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-0
content: 引用 1 楼 自信男孩的回复:#include<stdio.h> #include<stdlib.h>  typedef struct LNode {     int data;     struct LNode *next; }LNode,*LinkList;  int InitList(LinkList &L) {     L=(LinkList)malloc(sizeof(LNode));     if(L==NULL)         return false;     L->next=NULL;      return true; }  //store //int chucun (LinkList L,int a[],int i) int chucun (LinkList L,int a[], int len) {     int i = 0;     LinkList s;      while(i < len)     {         s = (LinkList)malloc(sizeof(LNode));         if (!s)             return -1;          s->data = a[i];         s->next = L->next;         L->next = s;          /*s->next=NULL;          L->data=a[i];         s->next  =L->next;         L->next=s;s->data=L->data;         */         i++;     }      return 0; } LinkList charu(LNode * L, int pos, int c) {     LinkList p;     int j=0,i=2;     p=L;     while(j < pos - 1 && p->next)     {         p=p->next;++j;     }     LinkList s;     s=(LinkList)malloc(sizeof(LNode));     s->data=c;     s->next=p->next;     p->next=s;      //return L->next;     return L; } int shanchu  (LinkList L, int i) {     LinkList p,s;     int j=0;     p=L;     //while(!(p->next)&&j<i-1){     while((p->next)&&j<i-1){         p=p->next,j++;     }     if (p->next == NULL)         return -1;      s = p->next;     p->next=s->next;     free(s);     s=NULL;      return 0; }  void printlist(LinkList L) {     LinkList temp = L->next;      printf("链表中的值为\n");     while(temp) {         printf("%d\n",temp->data);         temp=temp->next;     } }  //int main() int main(void) {     LinkList L;     InitList(L);     int a[]={11,22,33,44,66};     int i=0;     int c=55;     chucun(L, a, sizeof(a)/sizeof(a[0]));     printf("打印储存的链表\n");     printlist(L);     charu (L, 2, c);     printf("打印插入的链表\n");     printlist(L);     shanchu  (L ,5);     printf("打印删除后的链表\n");     printlist(L);      return 0; }  供参考～ 找到错误了，谢谢大佬

user: user-2
content: #include<stdio.h> #include<stdlib.h>  typedef struct LNode {     int data;     struct LNode *next; }LNode,*LinkList;  int InitList(LinkList &L) {     L=(LinkList)malloc(sizeof(LNode));     if(L==NULL)         return false;     L->next=NULL;      return true; }  //store //int chucun (LinkList L,int a[],int i) int chucun (LinkList L,int a[], int len) {     int i = 0;     LinkList s;      while(i < len)     {         s = (LinkList)malloc(sizeof(LNode));         if (!s)             return -1;          s->data = a[i];         s->next = L->next;         L->next = s;          /*s->next=NULL;          L->data=a[i];         s->next  =L->next;         L->next=s;s->data=L->data;         */         i++;     }      return 0; } LinkList charu(LNode * L, int pos, int c) {     LinkList p;     int j=0,i=2;     p=L;     while(j < pos - 1 && p->next)     {         p=p->next;++j;     }     LinkList s;     s=(LinkList)malloc(sizeof(LNode));     s->data=c;     s->next=p->next;     p->next=s;      //return L->next;     return L; } int shanchu  (LinkList L, int i) {     LinkList p,s;     int j=0;     p=L;     //while(!(p->next)&&j<i-1){     while((p->next)&&j<i-1){         p=p->next,j++;     }     if (p->next == NULL)         return -1;      s = p->next;     p->next=s->next;     free(s);     s=NULL;      return 0; }  void printlist(LinkList L) {     LinkList temp = L->next;      printf("链表中的值为\n");     while(temp) {         printf("%d\n",temp->data);         temp=temp->next;     } }  //int main() int main(void) {     LinkList L;     InitList(L);     int a[]={11,22,33,44,66};     int i=0;     int c=55;     chucun(L, a, sizeof(a)/sizeof(a[0]));     printf("打印储存的链表\n");     printlist(L);     charu (L, 2, c);     printf("打印插入的链表\n");     printlist(L);     shanchu  (L ,5);     printf("打印删除后的链表\n");     printlist(L);      return 0; }  供参考～