user-0 提问: dalao们帮忙看看这个链表哪里有问题orz~

回复:
user: user-1
content: #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 5 typedef struct stuNode {     char ID[15];     char name[10];     char sex[4];     char grade[5];     char major[20];     struct stuNode *next; }stuNode, * stuNodeP; stuNodeP headStu; #define LEN sizeof(stuNode) stuNodeP Create_StuList(int n) {     int i;     stuNodeP headStu;     stuNodeP p0, p1;     headStu = p0 = (stuNode *)malloc(LEN);     for (i = 1; i <= n; i++)     {         p1 = (stuNode *)malloc(LEN);         printf("请输入学生的学号，姓名，性别，班级，专业：\n");         scanf("%s%s%s%s%s",p1->ID,p1->name,p1->sex,p1->grade,p1->major);         p0->next = p1;         p0 = p1;     }     p1->next = NULL;     return headStu; } stuNodeP delete_StuList(stuNodeP headStu, char delID[15]) {     stuNodeP lp=0, p=0;      lp = headStu;     p = lp->next;      puts(delID);     while (p && strcmp(p->ID, delID) != 0) {         //puts(p->ID);         lp = p;         p = p->next;     }     if (!p) {         printf("没有查找到该名学生，无法删除！\n");         return headStu;     }     lp->next = p->next;     free(p);      /*     while ((strcmp(p->ID, delID) != 0) && (p->next != NULL))     {         lp = p;         p = p->next;     }     if (strcmp(p->ID, delID) == 0)     {         lp->next = p->next;         free(p);     }     else         printf("没有查找到该名学生，无法删除！\n");     */     return headStu; }  /* 添加有序，但是创建链表的时候并没有按照有序操作的，所以这里不能保证一直有意义*/ stuNodeP add(stuNodeP headStu, char newID[15]) {     stuNodeP p = headStu, q = headStu->next;     stuNodeP newstuNode;       newstuNode = (stuNode *)malloc(sizeof(LEN));     strcpy(newstuNode->ID, newID);     printf("请输入学生的学号，姓名，性别，班级，专业：");     scanf("%s%s%s%s%s",newstuNode->ID, newstuNode->name, newstuNode->sex, newstuNode->grade, newstuNode->major);      while (q && strcmp(q->ID, newID) < 0) {         p = p->next;         q = q->next;     }      if (!q) {         p->next = newstuNode;         newstuNode->next = NULL;         return headStu;     }      newstuNode->next = q;     p->next = newstuNode;      /*     //while((strcmp(q->ID, newID) < 0) && (q->next != NULL));   //多一个分号     while((strcmp(q->ID, newID) < 0) && (q->next != NULL))     {         p = p->next;         q = q->next;     }     newstuNode = (stuNode *)malloc(sizeof(LEN));     strcpy(newstuNode->ID, newID);     printf("请输入学生的学号，姓名，性别，班级，专业：");     scanf("%s%s%s%s%s",newstuNode->ID, newstuNode->name, newstuNode->sex, newstuNode->grade, newstuNode->major);     if (strcmp(q->ID, newID) < 0)         p = q;     newstuNode->next = p->next;     p->next = newstuNode;     */     return headStu; } void show(stuNodeP headStu) {     int num=0;     stuNode *p;     p = headStu->next;     while (p != NULL)     {         printf("%d:%s,%s,%s,%s,%s\n",++num, p->ID, p->name, p->sex, p->grade, p->major);         p = p->next;     } } int main() {     stuNodeP head;     char ID[15];     head = Create_StuList(N);     show(head);     printf("请输入要删除学生的学号信息：\n");     //scanf("%s", &ID);     scanf("%s", ID);     //head = delete_StuList(headStu, ID);     head = delete_StuList(head, ID);     show(head);     //head = add(headStu,ID);     head = add(head,ID);     show(head);     return 0; } 供参考～

user: user-0
content: 谢谢老师了~

user: user-2
content: 数据结构对单链表进行数据排序 http://bbs.csdn.net/topics/392201633

user: user-0
content: 有个报错， 引发了异常: 读取访问权限冲突。 **lp** 是 nullptr。