求高手指点:c语言运行出错:Invalid indirection.
struct students
{
int Number;
char Name[20];
float English;
float Maths;
float Cprogram;
float Average;
struct students *next;
};
struct students *head, *p1, *p2;
int n;
void ipt(void)
{
n = 0;
p1 = p2 = (struct students*)malloc(sizeof(struct students));
printf("Input students' record:Number Name English Maths Cprogram:");
scanf("%d%s%f%f%f", &p1->Number, &p1->Name, &p1->English, &p1->Maths, &p1->Cprogram);
head = NULL;
while(p1->Number!=0)
{
n++;
if (n = 1)
head = p1;
else p2->next = p1;
p2 = p1;
p1 = (struct students*)malloc(sizeof(struct students));
scanf("%d%s%f%f%f", &p1->Number, &p1->Name, &p1->English, &p1->Maths, &p1->Cprogram);
}
p2->next = NULL;
return;
}