[Solved] Reason for segmentation fault in this snippet of code [closed]


For logic as far as what I understood, you need to remove some flaws then your logic might work. try this one out :
for(i=1;i<=n;i++)
{
flag=0;
c=head;
while(c!=b)
{
if(c->d==b->d)
flag++;
c=c->next;
}
if(flag==0 && i==1)
{
a=(list)malloc(sizeof(node));
a->d=b->d;
a->next=NULL;
taila=a;
}
else if(flag==0)
{
new=(list)malloc(sizeof(node));
new->d=b->d;
new->next=NULL;
taila->next=new;
taila=new;
}

        b=b->next;
    }

1

solved Reason for segmentation fault in this snippet of code [closed]