“Supprimer le nœud de la liste liée” Réponses codées

Supprimer le nœud de la liste liée

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);
      }
    

}
Motionless Mink

supprimer le nœud de la liste liée C

int removeFrameNode(FrameNode** head, char* name)
{
	FrameNode* tmp = *head, *prev = NULL;;
	int foundNode = FALSE;

	while (tmp)
	{
		if (!strcmp(tmp->frame->name, name))
		{
			foundNode = TRUE;
			break;
		}
		prev = tmp;
		tmp = tmp->next;
	}
	if (foundNode)
	{
		if (tmp == *head)
		{
			*head = tmp->next;
		}
		else
		{
			prev->next = tmp->next;
		}
		free(tmp);
		return FOUND;
	}
	else
	{
		return NOT_FOUND;
	}
}
Proud Platypus

Réponses similaires à “Supprimer le nœud de la liste liée”

Questions similaires à “Supprimer le nœud de la liste liée”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code