指针错误了
#include<stdio.h>#include<string.h>
typedef struct student
{
char name[10];
int num;
float score;
struct student *next;
}student;
void namesearch(student *h,char n[])
{
student *p;
;
for(p=h;p!=NULL;p=p->next)
{
if(0==strcmp(p->name,n))
break;
}
if(p=NULL)
printf("该同学不存在!");
else
{
printf("%s\t%d\t%f\n",p->name,p->num,p->score);
}
}
int main()
{
student *h,s1={"wang",001,98},s2={"li",002,99},s3={"xu",003,78};
h=&s1;
s1.next=&s2;
s2.next=&s3;
s3.next=NULL;
namesearch(h,"li");
}
怎么p-name是一个错误的指针