高手帮帮我找一下程序的错误

来源:百度知道 编辑:UC知道 时间:2024/06/16 09:04:34
#include "stdio.h"
#include "conio.h"

#define NULL 0
#define LEN sizeof(struct student)
struct student
{
int num;
float score;
struct student *next;
};
int num;float score;
struct student *create(int n)
{
int i;
struct student *l;
struct student *p;
l = (struct student * )malloc(LEN);
l -> next = NULL;
for(i = n;i>0;i--)
{
p = (struct student * )malloc(LEN);
printf("%d:num=",i);
scanf("%d",&p->num);
printf("%d:score=",i);
scanf("%f",&p->score);
p->next = l->next;
l->next =p;
}
return(l);
}
struct student * listinsert(struct student * l,int i,int num,float score)
{
struct student *p,*s;
int j;
p = l;j=0;
while(p&&j<i-1)
{

没多看程序功能,上机运行,发现缺少头文件
#include <malloc.h>
加上就行,或者加#include <alloc.h>,这两个功能一样,随便一个就行。
因为你用到了malloc函数,加上后程序就没错误了,运行通过,- -||