搜索
查看: 221|回复: 0
打印 上一主题 下一主题

动态链表创建运行闪退

[复制链接]
跳转到指定楼层
楼主
 楼主| 发表于 2020-3-15 15:49:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5啊哈币
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>

  4. struct ScoLr{
  5.     int xh;
  6.     char* name;
  7.     float sco;
  8.     struct ScoLr* next;
  9. };

  10. struct ScoLr* CtJc(){
  11.     int i;
  12.     struct ScoLr *a, *b, *c;
  13.    
  14.     c = NULL;
  15.     b = NULL;
  16.     a = (struct ScoLr*)malloc(sizeof(struct ScoLr));
  17.     printf("输入信息:");
  18.     scanf("%d %s %f", &a->xh,a->name,&a->sco);
  19.     for(i=0;;i++){
  20.         if(a->xh==9999){
  21.             break;
  22.         }
  23.         else{
  24.             if(i==0){
  25.                 c = a;
  26.             }
  27.             else{
  28.                 b = a;
  29.                 a = (struct ScoLr*)malloc(sizeof(struct ScoLr));
  30.                 printf("输入信息:");
  31.                 scanf("%d %s %f", &a->xh,a->name,&a->sco);
  32.                 b->next = a;
  33.             }
  34.         }
  35.     }
  36.     a->next = NULL;
  37.     free(a);
  38.     free(b);
  39.     return c;
  40. }

  41. /*(){
  42.    
  43. }*/

  44. int main()
  45. {
  46.    struct ScoLr* head;
  47.    head = CtJc();
  48.    
  49.     return 0;
  50. }
复制代码
//这篇代码编译不报错,自查了几遍,但没找出问题,希望各位路过的能指点指点,提前谢谢了!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表