请帮我找出下面的程序中那里错了,谢谢

来源:百度知道 编辑:UC知道 时间:2024/07/02 06:47:13
#include<stdio.h>
#include<stdlib.h>
struct student
{ long num;
int score;
struct student *next;
};
#define LEN siaeof(struct student)
struct student *fun1()
{ struct student *head=NULL, *p1;
long num;
scanf("%ld",&num);
while(num!=0)
{ p1=(struct student *)malloc(LEN);
p1->num=num;
scanf("%d",&(p1->score));
p1->next=head;
head=p1;
scanf("%ld",&num);
}
return(head);
}
void fun2(struct student *head)
{ if(head==NULL) printf("no date!\n");
while(head!=NULL)
{ printf("%ld,%d\n",head->num,head->score);
head=head->next;
}
}
main()
{ struct student *head;
head=fun1();
fun2(head);
}

#define LEN siaeof(struct student)
这里sizeof 写错啦。
还有 在c++里面 主函数 需要还回值;
下面是我编译 0 error的

#include<stdio.h>
#include<stdlib.h>
struct student
{
long num;
int score;
struct student *next;
};
#define LEN sizeof(struct student)
struct student *fun1()
{
struct student *head=NULL, *p1;
long num;
scanf("%ld",&num);
while(num!=0)
{
p1=(struct student *)malloc(LEN);
p1->num=num;
scanf("%d",&(p1->score));
p1->next=head;
head=p1;
scanf("%ld",&num);
}
return(head);
}
void fun2(struct student *head)
{
if(head==NULL) printf("no date!\n");
while(head!=NULL)
{
printf("%ld,%d\n",head->num,head->score);
head=head->next;
}
}
int main()
{
struct s