0
Hello, I can’t understand what’s wrong with the code below. It was to add an element at the end of the linked list, but nothing happens and everything compiles without errors.
Can someone help me, please?
struct cel {
int info;
apontador prox;
apontador ant;
};
typedef struct cel * apontador;
void insereNoFim(int x, apontador lista) {
apontador aux = lista;
if (lista == NULL) {
lista = malloc(sizeof(struct cel));
lista->info = x;
lista->ant = lista->prox = NULL;
}
else {
while (aux->prox != NULL) {
aux = aux->prox;
}
aux->prox = malloc(sizeof(struct cel));
aux->prox->info = x;
aux->prox->ant = aux;
aux->prox->prox = NULL;
}
}
how so "nothing happens" ? what was to "happen" and not "happened" ? your question is very inaccurate
– zentrunix