Home > Back-end >  Bosses, help to see child beep
Bosses, help to see child beep

Time:12-14

#include
#include
# define NULL 0
Struct student
{long num.
float score;
Struct student * next;
};
int n;
Struct student * creat (void)
{
Struct student * head, * p1, * (p2);
head=NULL;
n=0;
P1=(struct student *) malloc (sizeof (struct student));
P1 p2=;
The scanf (" % ld % f ", & amp; P1 - & gt; Num, & amp; P1 - & gt; Score);
While (p1 - & gt; Num!=0)
{
n++;
If (head==NULL) head=p1;
The else p2 - & gt; Next=p;
P1 p2=;
P1=(struct student *) malloc (sizeof (struct student));
The scanf (" % ld % f ", & amp; P1 - & gt; Num, & amp; P1 - & gt; Score);
}
The p2 - & gt; Next=NULL;
Return (the head);
}

Int main ()
{
Struct student * pt;
Pt=creat ();
}
Why can appear such mistakes

CodePudding user response:

If (head==NULL) head=p1;
The else p2 - & gt; Next=p;
Assuming that the head is not null, then the chain table and the head to do not have what relation, finally returned to the head is obviously not right,
P1 p2=; The p2=head give it a try