5
I’m doing an activity proposed by a teacher, who asks to remove an element from the end of a double chained list. Except the function I set up to solve the problem is locking the program. In the resolution I thought that if made similar to a simple chained list would solve.
Follows 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);
    }
}