[Solved] What is wrong with the delete section? [closed]


Your deleter function should be like this.

void deleter (int n)
{
    el *p = start;
    el *prev = p;

    if (!start)
    {
        cout<<"Enfsad";
    }

    if(start->key == n)
    {
        start = start->next;
        delete prev;
    }
    else
    {
        while (p)
        {
            if(p->key == n)
            {
                prev->next = p->next;
                p->next = NULL;
                delete p; 
                break;
            }
            prev = p;
            p = p->next;
        }
    }
}

Although I think you need to check how a good linked list should be.

solved What is wrong with the delete section? [closed]