remove an element from a singly sorted linked list C++ -
i have sorted linked list , im trying create function delete whatever user passes nametosearch. keep geting error. below have far
void deleteproduct(nodeptr head, char* nametosearch) { nodeptr nodeunderedit = findnodebyname(head, nametosearch); if (nodeunderedit == null) { cout<<"\n error: product not found \n"; } else { delete nodeunderedit; nodeunderedit = nodeunderedit->next; } }
delete nodeunderedit; nodeunderedit = nodeunderedit->next;
if delete nodeunderedit
first, nodeunderedit->next
lost. need first make sure node before nodeunderedit's next connected nodeunderedit->next
, can remove.
Comments
Post a Comment