You didn’t show us the code for del_begin()
, but your del_end()
has a bug in the case you’re mentioning (single node list).
If you have only one node, your while
loop will never execute, and temp2
will be uninitialized when you get to the line:
temp2->nxt = NULL;
Crash!
6
solved Link lists in C++ (pt. 2) [closed]