Error in my Code(Deletion(Linked Lists))
The Number is not deleting(Pls.Help)
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct con {
int num;
struct con *next;
} node;
void take(node *list)
{
printf("\n\tEnter the Number(0 to END): ");
scanf("%d",&(*list).num);
if(list->num!=0)
{
list->next = (node *)malloc(sizeof(node));
take(list->next);
}
}
void printfrom(node *list)
{
printf("%d",list->num);
if(list->next->num!=0)
{
printf("->");
printfrom(list->next);
}
}
void del(node *list,int a)
{
if((*list).num==a)
{
list = (*list).next;
}
else del((*list).next,a);
}
int main()
{
printf("\n\t\t\tDeletion(Linked Lists)\n");
node *head;
int a;
head = (node *)malloc(sizeof(node));
take(head);
printfrom(head);
printf("\n\tEnter the Number you want to remove: ");
scanf("%d",&a);
del(head,a);
printfrom(head);
return 0;
}