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 have 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 elements, I introduced a new pointer to point to the last element and then add the new element. The program runs fine but when I ask for the main:
Lista_r=insertLastEfi(Nodo *L,Nodo *nv)
printf("%d\n",Lista_r->custo);
returns segmentation fault.
The insertLastEfi function is called 100 times to copy 100 values to the nodes in the list.