expected 'struct context *' but argument is of type 'struct context'是怎么回事
大神帮我看看哪里出错了,add函数定义那里出错,提示信息:[Note] expected 'struct context *' but argument is of type 'struct context'还有 else p=(struct context*)add(*p);这行出错信息:[Error] incompatible type for argument 1 of 'add'
#include<stdio.h>
#include<stdlib.h>
struct context
{
struct context *p1;
int n;
char s[10];
int score;
struct context *next;
};
struct context * crea()
{
struct context * p;
p=(struct context *)malloc(sizeof(struct context));
return (p);
}
struct context *add(struct context* p)
{
struct context *p1;
p1=(struct context *)malloc(sizeof(struct context));
p->next=p1;
p1->next=NULL;
return (p1);
}
int main()
{
int n;
struct context * start;
printf("1.创建链表%t2.显示学生信息%t3.学生成绩修改%t4.退出");
scanf("%d",&n);
do {
printf("\n输入序号:");
static struct context* p;
switch(n)
{
case 1:
{
static int n=1;char a;
do
{
if(n==1)
p=crea();
else p=(struct context*)add(*p);
printf("\n输入学生序号:");
scanf("d",p->n);
printf("\n输入学生姓名:");
scanf("%s",p->s);
printf("\n输入学生成绩:");
scanf("%d",p->score);
n++;
printf("a.继续输入%tb.停止输入");
scanf("%c",&a);
}while(a=='a'); break;
}
case 2:{
struct context *p1;
printf("学号 姓名 成绩 ");
p1=start;
while(p1!=NULL)
{
printf("%d %s %d ",p1->n,p1->s,p1->score);
p1=p1->next;
}
} break;
case 3:{
int n;
struct context *p1=start;
printf("输入学生学号:");
scanf("%d",&n);
while((p->n)!=n&&p1!=NULL)
if(p!=NULL)
p1=p1->next;
if(p1!=NULL)
{
printf("修改后成绩:");
scanf("%d",p1->score);
}
else printf("无此考生");
} break;
case 4: exit(0); break;
}
}
while(n!=4);
return 0;}