Hello, how I have reviewed my code but I can not see my error. Could someone enlighten me? The problem arises when trying to access 'end'. By removing these lines and de-commenting the lines that were already there, it works perfectly. I just want to add this pointer to facilitate data insertion
struct lista
{
int dato;
struct lista *siguiente;
struct lista *fin; //Nuevo apuntador a implementar.
};
void agregar(struct lista **primero, int r)
{
struct lista *nvo = (struct lista*)malloc(sizeof(struct lista));
if(nvo == NULL)
printf("\nERROR memoria insuficiente...\n");
else
{
nvo->dato = r;
nvo->siguiente = NULL;
if(*primero == NULL)
{
*primero = nvo;
*primero->fin = nvo; //Primer intento de acceder a fin
}
else
{
// Auxiliar para recorrer la lista
/*
struct lista *aux1;
aux1 = *primero;
while(aux1->siguiente != NULL)
aux1 = aux1->siguiente;
aux1->siguiente = nvo;
*/
*primero->fin->siguiente = nvo; //Segundo intento
*primero->fin = nvo; //Tercer intento
}
}
}