主题:急求高手帮忙
#include <stdio.h>
#include <stdlib.h>
typedf struct polynode
{ char name[6];
int num;
int score;
struct polynode *next;
} PNode;
PNode *Creat_Linklist(int n);
void print_Linklist(PNode *head);
main()
{
PNode *p;
int n;
printf("请输入学生的人数:\n");
scanf("%d",&n);
p=Creat_Linklist(n);
print_Linklist(p);
}
PNode *Creat_Linklist(int n)
{
PNode *head,*p,*q;
int i;
head=(PNode *)malloc(sizeof(PNode));
head->next=NULL;
p=head;
printf("请输入学生的信息:\n");
for(i=1;i<=n;i++)
{q=(PNode *)malloc(sizeof(PNode));
printf("姓名:");
scanf("%s",&q->name);
printf("学号:");
scanf("%d",&q->num);
printf("成绩:");
scanf("%d",&q->score);
q->next=NULL;
p->next=q;
p=q;
}
return(head);
}
void print_Linklist(PNode *head)
{ PNode *p;
p=head->next;
printf("姓名 学号 成绩\n ");
while(p)
{printf("%5s%5d%5d\n",p->name,p->num,p->score);
p=p->name;
}
}
运行怎么会出现error C2143: syntax error : missing ';' before '<class-head>'
error C2501: 'typedf' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
请高手帮忙改正
#include <stdlib.h>
typedf struct polynode
{ char name[6];
int num;
int score;
struct polynode *next;
} PNode;
PNode *Creat_Linklist(int n);
void print_Linklist(PNode *head);
main()
{
PNode *p;
int n;
printf("请输入学生的人数:\n");
scanf("%d",&n);
p=Creat_Linklist(n);
print_Linklist(p);
}
PNode *Creat_Linklist(int n)
{
PNode *head,*p,*q;
int i;
head=(PNode *)malloc(sizeof(PNode));
head->next=NULL;
p=head;
printf("请输入学生的信息:\n");
for(i=1;i<=n;i++)
{q=(PNode *)malloc(sizeof(PNode));
printf("姓名:");
scanf("%s",&q->name);
printf("学号:");
scanf("%d",&q->num);
printf("成绩:");
scanf("%d",&q->score);
q->next=NULL;
p->next=q;
p=q;
}
return(head);
}
void print_Linklist(PNode *head)
{ PNode *p;
p=head->next;
printf("姓名 学号 成绩\n ");
while(p)
{printf("%5s%5d%5d\n",p->name,p->num,p->score);
p=p->name;
}
}
运行怎么会出现error C2143: syntax error : missing ';' before '<class-head>'
error C2501: 'typedf' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
请高手帮忙改正