这段代码为什么输入值时会报错啊!!!
#include <stdio.h>
#include <string.h>
struct student
{
char *name;
int Num;
int score;
};
void order(struct student *p,int n)
{
int i,j;
struct student temp;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if((*(p+i)).score<(*(p+j)).score)
{
temp=*(p+i);
*(p+i)=*(p+j);
*(p+j)=temp;
}
}
void find(struct student *p,char *name,int n)
{
int i;
printf("name: ");
puts(name);
for(i=0;i<n;i++)
if(strcmp((*(p+i)).name,name)==0) printf("Order: %d",i+1);
}
void main()
{
struct student s[30],*p=s;
int i;
char *name;
for(i=0;i<30;i++)
{
flushall();
gets(s[i].name);
scanf("%d%d",&s[i].Num,&s[i].score);
}
order(p,i);
printf("input a name");
gets(name);
printf(" * * * * * * * * * * Order Table * * * * * * * * * * \n");
printf(" No Name Num Score\n");
for(i=0;i<30;i++)
{
printf(" %d ",i+1);
puts(s[i].name);
printf(" %d %d\n",s[i].Num,s[i].score);
}
find(p,name,i);
}
请各位帮忙找下问题啊,当输入完第一项数据,一敲回车就报错!这是什么原因!!!