Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

delete node from linked list

void deleteNode(struct node **head, int key)
{
      //temp is used to freeing the memory
      struct node *temp;
     

      //key found on the head node.
      //move to head node to the next and free the head.
      if(*head->data == key)
      {
          temp = *head;    //backup the head to free its memory
          *head = (*head)->next;
          free(temp);
      }
    

}
Source by www.log2base2.com #
 
PREVIOUS NEXT
Tagged: #delete #node #linked #list
ADD COMMENT
Topic
Name
8+4 =