啊哈磊_编程从这里起步
标题:
动态链表创建运行闪退
[打印本页]
作者:
112233c
时间:
2020-3-15 15:49
标题:
动态链表创建运行闪退
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct ScoLr{
int xh;
char* name;
float sco;
struct ScoLr* next;
};
struct ScoLr* CtJc(){
int i;
struct ScoLr *a, *b, *c;
c = NULL;
b = NULL;
a = (struct ScoLr*)malloc(sizeof(struct ScoLr));
printf("输入信息:");
scanf("%d %s %f", &a->xh,a->name,&a->sco);
for(i=0;;i++){
if(a->xh==9999){
break;
}
else{
if(i==0){
c = a;
}
else{
b = a;
a = (struct ScoLr*)malloc(sizeof(struct ScoLr));
printf("输入信息:");
scanf("%d %s %f", &a->xh,a->name,&a->sco);
b->next = a;
}
}
}
a->next = NULL;
free(a);
free(b);
return c;
}
/*(){
}*/
int main()
{
struct ScoLr* head;
head = CtJc();
return 0;
}
复制代码
//这篇代码编译不报错,自查了几遍,但没找出问题,希望各位路过的能指点指点,提前谢谢了!
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2