Home > Back-end >  Debugging process in the wrong place, but I don't know how to change. The book code is such, bu
Debugging process in the wrong place, but I don't know how to change. The book code is such, bu

Time:09-23

Void insert (node * head, int, int x)
{
The node * p=head - & gt; Next, * q;
Int k=0;
If (i<1)
Cout<& lt;" There is no the first "& lt; & lt; i<& lt;" A location "& lt; & lt; Endl;
The else
{
While (p!=NULL& & K{
Node * q=p - & gt; Next; -- -- -- -- -- - in the process of debugging the wrong places, but don't know how to change, the book's code is such, but in here is alright, C - free5.0
P=q;
K++;
}
If (p=NULL)
Cout<& lt;" Beyond the list can be inserted into the largest position!" & lt; & lt; Endl;
The else
{
Node * q=new node;
Q - & gt; data=https://bbs.csdn.net/topics/x;
Q - & gt; Next=p - & gt; Next;
P - & gt; Next=q;
}
}
}

CodePudding user response:

The third line node * p=head - & gt; Next, * q;

Node * q=p - & gt; Next; -- -- -- -- -- - the wrong place in the process of debugging,

Defines the two * q, will this reason?

CodePudding user response:

After I remove the q or not,
  • Related