Home > Back-end >  Trouble ask list delete node code which is wrong
Trouble ask list delete node code which is wrong

Time:09-22

Void english_list: : delist ()
{
Char name1 [10].
Cout<& lt;" Please enter a name: to delete ";
cin> Name1.
P=the head;
While (p)
{
If (STRCMP (name1, p - & gt; Name)==0)
{
Cout<& lt;" To find the man and remove "& lt; The delete p;
}
The else
P=p - & gt; Next;
}
Cout<& lt;" Not found this person, unable to delete "& lt; }

CodePudding user response:

What are you doing else is used for? No if
In the while (p - & gt; Next!=null)
{...
P=p - & gt; Next;
}
Delete the else

CodePudding user response:

 
Void english_list: : delist ()
{
Char name1 [10].
Cout<& lt;" Please enter a name: to delete ";
cin> Name1.
P=the head;
np=head;
While (p)
{
np=p - & gt; Next;
If (STRCMP (name1, p - & gt; Name)==0)
{
Cout<& lt;" To find the man and remove "& lt; The delete p;
}
//else
P=np.
}
Cout<& lt;" Not found this person, unable to delete "& lt; }
More 0

CodePudding user response:


Void english_list: : delist ()
{
Char name1 [10].
Cout<& lt;" Please enter a name: to delete ";
cin> Name1.
P=the head;
Np=head;//
While (p)
{
Np=p - & gt; Next;//
If (STRCMP (name1, p - & gt; Name)==0)
{
Cout<& lt;" To find the man and remove "& lt; & lt; Endl;
The delete p;
}
//else
P=np.
}
Cout<& lt;" Not found this person, unable to delete "& lt; }

CodePudding user response:

 
Void english_list: : delist ()
{
Char name1 [10].
Cout<& lt;" Please enter a name: to delete ";
cin> Name1.
P=the head;
Np=head;//
While (p)
{
Np=p - & gt; Next;//
If (STRCMP (name1, p - & gt; Name)==0)
{
Cout<& lt;" To find the man and remove "& lt; The delete p;
}
//else
P=np.
}
Cout<& lt;" Not found this person, unable to delete "& lt; }


What the devil typesetting,,, die trouble,,

CodePudding user response:

Is that you get upstairs, the building must be the subsequent data before delete a pointer to the preserved, otherwise lost,
  • Related