结构体链表,为什么老出错,弄不清楚了!!!
程序代码:#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct student)
struct student
{
int num;
float score;
struct student *next;
}
int n;
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
head=NULL;
n=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%d,%f",&p1->num,&p1->score);
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p1=(struct student*)malloc(LEN);
scanf("%d,%f",p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
为什么连连报错,我都觉得没错啊!报错是这样显示的
--------------------Configuration: porgram_lianbiao - Win32 Debug--------------------
Compiling...
porgram_lianbiao.c
D:\MSDev98\porgram_lianbiao\porgram_lianbiao.c(10) : error C2628: 'student' followed by 'int' is illegal (did you forget a ';'?)
D:\MSDev98\porgram_lianbiao\porgram_lianbiao.c(16) : error C2115: '=' : incompatible types
D:\MSDev98\porgram_lianbiao\porgram_lianbiao.c(20) : error C2088: '+' : illegal for struct
D:\MSDev98\porgram_lianbiao\porgram_lianbiao.c(21) : error C2088: '==' : illegal for struct
Error executing cl.exe.
porgram_lianbiao.obj - 4 error(s), 0 warning(s)
高手解释下,哪里错了? 快啊
[ 本帖最后由 lyj23 于 2011-2-13 15:54 编辑 ]









