#include
#include
#define LEN sizeof(struct Student)
struct Student
{long num;
float score;
struct Student *next;
};
int n;
struct Student *creat()
{
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 p2->next=p1;
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;
printf("\nNow,These %d records are:\n",n);
p=head;
if(head!=NULL)
do
{printf("%ld %5.1f\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
}
void main()
{
struct Student* head;
head=creat();
print(head);
}
错误提示如下,求解:C:\Documents and Settings\jsj\桌面\ex.9.10.c(21) : warning C4133: '=' : incompatible types - from 'struct Student *' to 'struct student *'
C:\Documents and Settings\jsj\桌面\ex.9.10.c(28) : warning C4133: 'return' : incompatible types - from 'struct student *' to 'struct Student *'
C:\Documents and Settings\jsj\桌面\ex.9.10.c(33) : error C2115: '=' : incompatible types
C:\Documents and Settings\jsj\桌面\ex.9.10.c(34) : error C2088: '!=' : illegal for struct
C:\Documents and Settings\jsj\桌面\ex.9.10.c(45) : error C2115: 'function' : incompatible types
C:\Documents and Settings\jsj\桌面\ex.9.10.c(45) : warning C4024: 'print' : different types for formal and actual parameter 1
谢谢