Código:
#include <iostream>
#include <cstdlib>
using namespace std;
struct t_nodo
{
int dato;
struct t_nodo *siguiente;
};
void insertar_al_final (struct t_nodo *&p);
int main(void)
{
struct t_nodo *principio;
cout << "\n---- INSERTAR AL FINAL ----";
cin.get();cin.get();
insertar_al_final(principio);
return 0;
}
//FUNCION INSERTAR AL FINAL
void insertar_al_final(struct t_nodo *&p)
{
struct t_nodo *nuevo_nodo;
struct t_nodo *aux;
nuevo_nodo = new struct t_nodo;
cout << "Introduzca el numero: ";
cin >> nuevo_nodo->dato;
nuevo_nodo->siguiente = NULL;
if (p != NULL)
{
aux = p;
while (aux->siguiente != NULL) //aqui es donde marca el problema
{
aux = aux->siguiente;
}
aux->siguiente = nuevo_nodo;
}
else
{
p = nuevo_nodo;
}
}
El resultado del depurador esta en esta imagen:
http://postimg.org/image/xlcxnptrn/
Toda ayuda es bienvenida. Muchas gracias ^^