建立链表,错在哪里?
以下是一个子函数,编译时却出现了很多错误请问是为什么?
error: expected `while' before "student"
error: expected `(' before "student"
error: expected primary-expression before '*' token
error: expected primary-expression before "void"
error: expected `)' before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[5]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: invalid conversion from `student*' to `int'
struct student *creat(void) /*建立动态链表,制作学生成绩单*/
{
struct student *head;
struct student *p1,*p2;
p1=p2=(struct student*)malloc(LEN);/*开辟一个新单元*/
p1->num=1,p1->name="周润发",p1->score[3]={80.00,74.50,91.00};
head=NULL;
for(n=1;n<6;n++)
{
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student*)malloc(LEN);
switch(n)
{
case 2:p1->num=2,p1->name="刘德华",p1->score[3]={83.00,64.00,75.00};break;
case 3:p1->num=3,p1->name="张学友",p1->score[3]={90.00,69.00,81.50};break;
case 4:p1->num=4,p1->name="郭富城",p1->score[3]={73.00,62.00,79.00};break;
case 5:p1->num=5,p1->name="黎明",p1->score[3]={85.50,84.00,78.00};break;
}
}
p2->next=NULL;
return(head);
}