找不到错。。。。。郁闷。

来源:百度知道 编辑:UC知道 时间:2024/05/16 18:26:09
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct stud
{ char name[10];
int num,s[4];
double ave;
struct stud *next;
};
typedef struct stud xuesheng;
void readrec(xuesheng *);
void main()
{ xuesheng *p;
p=NULL;
readrec(p);

}
void readrec(xuesheng *p)
{ char b[10];
int k=0,n[4],a=1;
double i=0;
xuesheng *o=NULL,*r=NULL;
if((p=(xuesheng *)malloc(sizeof(xuesheng)))==NULL)
{printf("没有内存");
exit(0);
}
else
{
r=p;
while(a!=0)
{if((o=(xuesheng *)malloc(sizeof(xuesheng)))==NULL)
{printf("没有内存");
exit(0);
}
else
{
if(b==NULL)
{scanf("%d %s %d %d %d %d",&a,b,n[0],n[1],n[2],n[3]);
strcpy(o->name,b);
o->num=a;
o->s[0]=n[0];
o->s[1]=n[1];
o->s[2]=n[2];
o-

同学只是最后少一个'}'符号

其实建议同学在写程序的时候,最好是用梯形的形式,就是函数里面有算法的话比如:
main()
{
for()
{
while()
{
for()
{
}

}
}
}
这样的话在括号比较多的时候不会多或少