ProAnswers.org

How to delete a node from a linked list

How to delete a node from a linked list

In C the implementation would be something as this:

	typedef struct node
	{
	int data;
	struct node *next;
	}node;



	void delete_node(node *head, node *del)
	{
	node *move;
	for(move=head;move->next!=del;move=move->next);
	move->next = del->next;
	del->next = NULL;
	free(del);
	}