编译时提示出了两个错.代码如下:
#define NULL 0
#define LEN sizeof(struct ks)
#include<stdio.h>
#include<stdlib.h>
int n;
struct ks /*结构体声明*/
{
long num;
int score;
struct ks *next;
}
struct ks *create() /*第一个错误,“Too many types in declaration."*/
{
struct ks *head,*p1,*p2;
n=0;head=p2=NULL;
p1=(struct ks *)malloc(LEN); /*为一个结构体开辟一个空间*/
p1->next=NULL;
scanf("%ld%d",&p1->num,&p1->score);
while(p1->num!=0)
{
++n;
if(n==1)head=p1; /*第一次输入,做表头*/
else p1->next=p2; /*否则接到表尾*/
p2=p1;
p1=(struct ks *)malloc(LEN); /*开辟下一个空间*/
scanf("%ld%d",&p1->num,&p1->score);
p1->next=NULL;
}
free(p1);
return(head);
}
void output(*head) /*第二个错误,"Declaration syntax error."*/
{
struct ks *p;
p=head;
do
{
printf("%ld%-6d\n",p->num,p->score);
p=p->next;
}while(p!=NULL)
}
main()
{
struct ks &pe;
pe=create();
output(pe);
}