Fast solution is to copy the data from the next node to the node to be deleted and delete the next node. Something like following.
struct node *temp = node_ptr->next;
node_ptr->data = temp->data;
node_ptr->next = temp->next;
free(temp);
void deleteNode(struct node *node_ptr){ struct node *temp = node_ptr->next; node_ptr->data = temp->data; node_ptr->next = temp->next; free(temp);}
This solution doesn’t work if the node to be deleted is the last node of the list. To make this solution work we can mark the end node as a dummy node. But the programs/functions that are using this function should also be modified.