->num' must point to class/struct/union请问哪里出错了
--------------------Configuration: xx - Win32 Debug--------------------
Compiling...
xx.cpp
C:\Documents and Settings\Administrator\桌面\xx.cpp(19) : error C2027: use of undefined type 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(9) : see declaration of 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(20) : error C2065: 'sanf' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\xx.cpp(20) : error C2027: use of undefined type 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(9) : see declaration of 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(20) : error C2227: left of '->num' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\xx.cpp(20) : error C2027: use of undefined type 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(9) : see declaration of 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(20) : error C2227: left of '->score' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\xx.cpp(22) : error C2027: use of undefined type 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(9) : see declaration of 'Student'
C:\Documents and Settings\Administrator\桌面\xx.cpp(22) : error C2227: left of '->num' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\xx.cpp(22) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.
xx.exe - 1 error(s), 0 warning(s)
# include <stdio.h>
# include <malloc.h>
# define LEN sizeof(struct Student)
struct Srudent
{
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);
sanf("%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 prin(struct Student head)
{
struct Student * p;
pintf("\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();
prin(head);
}
请教一下大家