lundi 17 septembre 2018

function not work as expected segmentation fault

struct node *first = NULL, *second = NULL;

void secondl()

{

while (top != NULL)

{

    if (top->x > first->x) {

        second = first;

        first = top;
    }

    else if (top->x > second->x && top->x != first->x)

    {
        second = top;
    }

    top = top->next;
}

printf("first -> %d\n", first->x);
printf("second -> %d\n", second->x);

}

segmentation fault (core dumped)

Aucun commentaire:

Enregistrer un commentaire