I am doing an activity proposed by a teacher, which asks you to remove an element from the end of a double chained list. But the function I put together to solve the problem is locking the program. In the resolution I thought that if it were made similar to a simple threaded list would solve.
Follow the code:
int Remover_fim_LD (Tno_ld **inicio){
Tno_ld *aux, *percorre;
if(*inicio == NULL)
{
printf("\n Lista vazia! \nRemocao impossivel\n");
return 1;
}
else
{
percorre = *inicio;
while(percorre -> prox != NULL)
{
aux = percorre;
percorre = percorre -> prox;
}
(percorre -> ant) -> prox = percorre -> prox;
(percorre -> prox) -> ant = percorre -> ant;
percorre -> prox = NULL;
free(percorre);
}
}