注册 登录
编程论坛 新人交流区

[求助]关于建立动态链表的问题

dou 发布于 2007-10-15 15:44, 416 次点击

#include <stdio.h>

#include <malloc.h>
#define LEN sizeof(stuct student)

struct student
{long num;
float score;
struct student *next;}

main()
{
struct student a,b,c,*head,*p1,*p2,*p3;
head=NULL;
p1=p2=(struct student*)malloc(LEN);
scanf("%ld,%f",p1->num,p1->score );
if(p1->num=0) head=NULL;
else
{head=p1;
while(1)
{ p1=(struct student*)malloc(LEN);
scanf("%ld,%f",p1->num,p1->score );
if(p1->num!=0)
{
p2->next=p1;
p2=p1;
}
else p2->next=NULL;
if (p2->next==NULL)
break;
}

}

}
P3=head;
while(p!=NULL)
{printf("%ld,%f",p3->num,p3->score);
p3=p3->next;
}


}

---Configuration: dddde - Win32 Debug--------------------
Compiling...
d.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\dddde\d.cpp(12) : error C2628: 'student' followed by 'void' is illegal (did you forget a ';'?)
D:\Program Files\Microsoft Visual Studio\MyProjects\dddde\d.cpp(41) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

dddde.exe - 2 error(s), 0 warning(s)请问新手,请指点哈兹。。。

[此贴子已经被作者于2007-10-15 16:12:57编辑过]

0 回复
1