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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -