0
typedef struct NODO{
int custo;
int linha;
int coluna;
struct NODO *nseg[2];
}Nodo;
Nodo * insertLastEfi(Nodo *L,Nodo *nv){
Nodo * aux =L;
if (L==NULL) {
return nv;
}
while (L->nseg[1]!=NULL) {
L=L->nseg[1];
}
L->nseg[1]=nv->nseg[1];
L->nseg[0]=nv->nseg[0];
return aux;
}
I implemented the following function mentioned above. What I want to do is:
to insert a new element in the list and instead of going through all the elements, I introduced a new pointer to point to the last element and then add the new element. The program goes well but when I ask in the main:
Lista_r=insertLastEfi(Nodo *L,Nodo *nv)
printf("%d\n",Lista_r->custo);
returns Segmentation fault.
The function insertLastEfi is called 100 times to copy 100 values to list nodes.