简单链表输入输出,不知道问题在哪?求大神指教。
#include<stdio.h>#include "malloc.h"
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
float score;
struct student*next;
};
int n;
struct student *create()
{
struct student*head;
struct student*p1,*p2;
n=0;
p1=p2=(struct student *) malloc (LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1) head=p1;
else p1=p2->next;
p2=p1;
p1=(struct student*) malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
void print(struct student head)
{struct student* p;
p=head;
if(head!=NULL)
do
{
printf("num=%ld score=%5.1f\n", p->num, p->score);
p = p->next;
} while (p!=NULL);
}
int main()
{ struct student*head;
head=create();
print(head);
return 0;
}
编译问题:
1. error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct student' (or there is no acceptable conversion)
2.error C2676: binary '!=' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
3.error C2664: 'print' : cannot convert parameter 1 from 'struct student *' to 'struct student'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.