Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/12/2013, 16:03
Javieer-G
 
Fecha de Ingreso: diciembre-2008
Mensajes: 50
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Borrar un elemento en una lista enlazada

Bueno gente, después de mucho deliberar, prueba y error, he conseguido definir el algoritmo. Gracias de todos modos. Dejo el código por si a alguno le interesa:

Código C:
Ver original
  1. void borrarReferencia(ref_info **lista, int ID){
  2.     ref_info *q =  nuevaRef();
  3.     q =  *lista;
  4.    
  5.     while(q->next->ID != ID && q->next->titulo != NULL){
  6.         q = q->next;
  7.     }
  8.    
  9.     if (q->next == NULL){
  10.       printf("Error: posicion fin.\n");
  11.       return;
  12.     }
  13.    
  14.     ref_info *aux = nuevaRef();
  15.    
  16.     aux = q->next;
  17.     q->next = aux->next;
  18.    
  19.     free(aux);
  20.    
  21.  
  22. }