Home > Back-end >  C list problem, the output is garbled
C list problem, the output is garbled

Time:09-22

Really big don't know what wrong

CodePudding user response:

The create wrong inside the while loop conditions, '\ 0' is a string terminator, not terminated int array, you can pass in an array length

CodePudding user response:

I changed, is still gibberish, cycles of the output is correct, p - & gt; Id output is right, I guess should be p - & gt; The order output error

CodePudding user response:

reference 1/f, Simple, Soft reply:
create wrong inside the while loop conditions, '\ 0' is a string terminator, not terminated int array, you can pass in an array length in

I changed, is still gibberish, cycles of the output is correct, p - & gt; Id output is right, I guess should be p - & gt; The order output error

CodePudding user response:

The new code also posted, the new output results also posted, have a look at where is wrong, really not line, you can debug, see which step go wrong

CodePudding user response:

refer to 4th floor, Simple, Soft reply:
also posted the new code, stick the new output results come out, have a look at where is wrong, really not line, you can see which step go wrong debugged,

The changed:
Order * creat (int pa [], int []) in pb//build unordered list, Order of the two restaurants are merged into a linked list,
{
int i=0;
The Order * (p1, p2, * head=NULL;
While (i<5)
{
P1=new Order;
P1 - & gt; Id='A';
P1 - & gt; The order=pa [I];
If (head==NULL) head=p1;
The else p2 - & gt; The link=p1;
P1 p2=;
i++;
}
i=0;
While (i<5)
{
P1=new Order;
P1 - & gt; Id='B';
P1 - & gt; The order=pb [I];
If (head==NULL) head=p1;
The else p2 - & gt; The link=p1;
P1 p2=;
i++;
}
If (the head) p2 - & gt; The link=NULL;
return head;
}

CodePudding user response:

refer to 4th floor, Simple, Soft reply:
also posted the new code, stick the new output results come out, have a look at where is wrong, really not line, you can see which step go wrong debugged,

Output: A112148A312148A512148A012148A012148B212148B412148B612148B012148B012148

CodePudding user response:

refer to 4th floor, Simple, Soft reply:
also posted the new code, stick the new output results come out, have a look at where is wrong, really not line, you can see which step go wrong debugged,

Ah ha! The whole understand is TAB \ play against
  • Related