Home > Back-end >  Why little notes that when the output is wrong
Why little notes that when the output is wrong

Time:12-26

# include "head h"
New list *//*
Struct STD * the create ()
{
If (head==NULL)
{
Struct STD * p;
The head=NULL;
P=(struct STD *) malloc (sizeof (struct STD));
Printf (" Number \ tName \ tChinese \ tMath \ tEnglish \ n ");
Lf the scanf (" % d % s % % % lf lf ", & amp; p-> Num, p - & gt; The name, & amp; p-> Score [0], & amp; p-> Score [1], & amp; p-> Score [2]);
while(p-> Num!=0)
{
The head=insertdoc (head, p);
P=(struct STD *) malloc (sizeof (struct STD));/* why fewer words of this strange */
Lf the scanf (" % d % s % % % lf lf ", & amp; p-> Num, p - & gt; The name, & amp; p-> Score [0], & amp; p-> Score [1], & amp; p-> Score [2]);
}
Free (p);
Printf (" new success... \n");
}
The else
Printf (" already exist, don't need new again \ n ");
return head;
}

CodePudding user response:

What's wrong?

Create a list, first apply for node, then insert the list,

CodePudding user response:

Suppose your kettle fell only five cups of water, you pour out, now don't you add some water, how to continue to fall

CodePudding user response:

refer to the second floor xws245925587 response:
suppose your kettle fell only five cups of water, you pour out, now what don't you add some water, continue to pour

This is equivalent to you to create a new list out, you shall not give him the allocated memory

CodePudding user response:

refer to the second floor xws245925587 response:
suppose your kettle fell only five cups of water, you pour out, now what don't you add some water, continue to pour

Why repeat application, each input to apply for once, I didn't release the p
  • Related