帮我看下面C语言程序哪出错了

来源:百度知道 编辑:UC知道 时间:2024/05/15 12:03:36
#define LEN sizeof(struct stu)
#include<stdio.h>
#include<alloc.h>//电脑提示打不开这样的文件,我该怎么办
struct stu
{
int num;
char name[20];
int age;
struct stu *next;
};
struct stu *creat()
{
struct stu *head;
struct stu *p;
struct stu *pr,*pn;
int x;
head=NULL;
scanf("%d",&x);
while(x!=0)
{
p=(struct stu *)malloc(LEN);
p->num=x;
gets(p->name);
scanf("%d",&(p->age));
p->next=NULL;
if(head==NULL) head=p;
else
{
pn=head;
while(p->num>pn->num && pn!=NULL)
{
pr=pn;
pn=pn->next;
}
}
if(pn==NULL) pr->next=p;
else
{
p->next=pn;
pr->next=p;
};
scanf("%d",&x);
}
return head;
}
void list(struct stu *head)
{
struct stu *p;
printf("

你的编译器里面没有alloc.h这个头文件。上网上下一个这个头文件就复制到nclude这个文件夹下。
在我这里这个程序编译通过。

#include<alloc.h>//电脑提示打不开这样的文件,我该怎么办
答:把#include<alloc.h>改为#include<malloc.h>。