CODE NOT WORKING

code not working i tried dry running it and it seems fine

hey @ranahiten8 you have mentioned wrong odd even problem while posting this doubt. Attach the problem of linked list odd even so that i can get the correct problem link to help you.

Its the linked list odd even code . Recheck again please.

your this part of code is causing issue

while (n-- > 0)
    {
        flag = check(curr->data);
        if (curr == head)
        {
            if (flag)
            {
                
                head = head->next;
                curr->next = NULL;
                tail->next = curr;
                tail = tail->next;
                curr = head;
            }
            prev == curr;
            curr = curr->next;
            
        }
        else
        {
            if (flag)
            {
               
                prev->next = curr->next;
                nex=curr->next;
                curr->next = NULL;
                tail->next = curr;
                tail = tail->next;
            }
            curr = nex;
        }
    }

you are accessing that address in this part of code which is out of bound. that’s why seg fault. Do what make 2 head linked list, L1 & L2, if any odd element is found push it in L1 ,if any even element is found push it in L2 then make l1->tail = l2->head to connect them. This will be an easy implementation for you.

What is meant by out of bound?

memory or address that is not defined.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.