I tried to delete the second node in list
1 2 3Code:#include<stdio.h>
#include<stdlib.h>
struct Node
{
int data;
struct Node *next;
};
int main()
{
struct Node* head = NULL;
struct Node* second = NULL;
struct Node* third = NULL;
head = (struct Node*)malloc(sizeof(struct Node));
second = (struct Node*)malloc(sizeof(struct Node));
third = (struct Node*)malloc(sizeof(struct Node));
head->data = 1;
printf(" %d ", head->data);
head->next = second;
second->data = 2;
printf(" %d ", second->data);
second->next = third;
free(second);
third->data = 3;
printf(" %d ", third->data);
third->next = NULL;
return 0;
}
free(second);
but It doesn't delete