user-0 提问: 单线链表报错，是我的指针用得有问题吗？

回复:
user: user-1
content: #include<stdio.h> #include<stdlib.h> #include<string.h>  struct stud_node {     int num;     char name[20];     int score;     struct stud_node* next; };  struct stud_node* Create_Stu_Doc(); struct stud_node* InsertDoc(struct stud_node* head, struct stud_node* stud); struct stud_node* DeleteDoc(struct stud_node* head, int num); void Print_Stu_Doc(struct stud_node* head);  int main(void) {     struct stud_node* head = NULL, * p;     int choice, num, score;     char name[20];     int size = sizeof(struct stud_node);      do {         printf("1:Creat 2:Insert 3:Delete 4:Print 0:Exit\n");         scanf_s("%d", &choice);         switch (choice) {             case 1:                 head = Create_Stu_Doc();                 break;             case 2:                 printf("Input num,name and score:\n");                 scanf_s("%d%s%d", &num, name, 20, &score);                 p = (struct stud_node*)malloc(size);                 p->num = num;                 p->score = score;                 strcpy_s(p->name, 20, name);                 head = InsertDoc(head, p);                 break;             case 3:                 printf("Input num:\n");                 scanf_s("%d", &num);                 head = DeleteDoc(head, num);                 break;             case 4:                 Print_Stu_Doc(head);                 break;         }      } while (choice != 0);      return 0; }  /*新建链表*/ struct stud_node* Create_Stu_Doc() {     struct stud_node* head, * p;     int num, score;     char name[20];     //int size = sizeof(struct stud_node*);    //此处申请的空间大小有问题     int size = sizeof(struct stud_node);      head = NULL;     printf("Input num,name and score:\n");     scanf_s("%d%s%d", &num, name, 20, &score);     while (num != 0) {         p = (struct stud_node*)malloc(size);         p->num = num;         p->score = score;         strcpy_s(p->name, 20, name);         head = InsertDoc(head, p);         scanf_s("%d%s%d", &num, name, 20, &score);     }     return head; }  struct stud_node* InsertDoc(struct stud_node* head, struct stud_node* stud) {     struct stud_node* ptr, * ptr1 = NULL, * ptr2;     ptr2 = head;     ptr = stud;     if (head == NULL) {         head = ptr;         head->next = NULL;         return head;     }     //if ((ptr2->next != NULL) && (ptr->num > ptr2->num)) {     while (ptr2  && (ptr->num > ptr2->num)) {         ptr1 = ptr2;         ptr2 = ptr2->next;     }     if (!ptr2) {         ptr1->next = ptr;         ptr->next = NULL;     } else {         if (head == ptr2) {             ptr->next = head;             head = ptr;             return head;         }         ptr1->next = ptr;         ptr->next = ptr2;     }     /*     if (ptr->num <= ptr2->num) {         if (head == ptr2) {             ptr->next = head;             head = ptr;             return head;         }         ptr1->next = ptr;         ptr->next = ptr2;     } else {         ptr2->next = ptr;         ptr->next = NULL;     }     */      return head; }  /*删除成绩小于60分的学生*/ struct stud_node* DeleteDoc(struct stud_node* head, int num) {     struct stud_node* ptr1, * ptr2;     while (head != NULL && head->num == num)     {         ptr2 = head;         head = head->next;         free(ptr2);     }     if (head == NULL)         return NULL;      ptr1 = head;     ptr2 = head->next;     while (ptr2 != NULL)     {         if (ptr2->num == num) {             ptr1->next = ptr2->next;             free(ptr2);         }         else {             ptr1 = ptr2;             ptr2 = ptr2->next;         }     }     return head; }  void Print_Stu_Doc(struct stud_node* head) {     struct stud_node* ptr;     if (head == NULL) {         printf("\nNo Records\n");         return;     }     printf("\nThe Studens' Records Are:\n");     printf("Num\t Name\t Score\n");     //for (ptr = head; ptr->next != NULL; ptr = ptr->next) {     for (ptr = head; ptr != NULL; ptr = ptr->next) {         printf("%d\t%s\t%d\n", ptr->num, ptr->name, ptr->score);     }  }   供参考～

user: user-2
content: int size = sizeof(struct stud_node* ); 敲错了，这个size在32位机器上永远是4，因为是地址

user: user-3
content: 数据结构对单链表进行数据排序 http://bbs.csdn.net/topics/392201633  崩溃的时候在弹出的对话框按相应按钮进入调试，按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处，看不懂时双击下一行，直到能看懂为止。

user: user-4
content: 手抖打错了几行代码吧~~   31 行	scanf_s("%d%s%d", &num, name, 20 , &score);   加上20  59行  int size = sizeof(struct stud_node* ); 把*去掉。