Void InsertDataByTail (LinkList * head) { DataType x; LinkList * remove; LinkList * node; While (NULL!=the head - & gt; Next) The head=head - & gt; Next; Remove=head; Printf (" input the data (1) stop \ n "); The scanf (" % d ", & amp; X); While (x!=1) { The node=(LinkList *) malloc (sizeof (LinkList)); Node - & gt; Data=https://bbs.csdn.net/topics/x; Node - & gt; Next=remove - & gt; Next; Remove - & gt; Next=node; Remove=node; The scanf (" % d ", & amp; X); } }
Void ShowListData (LinkList * head) { The head=head - & gt; Next; Printf (" output list \ n "); While (NULL!=head) { Printf (" % d ", the head - & gt; The data); The head=head - & gt; Next; } printf("\n"); }
CodePudding user response:
Are you sure you have to move the cursor to traverse the entire each node in the list. When the cursor moves to the last element, print pointer move back again, after the last node of the subsequent is NULL