I'm getting a runtime error, and I can't figure out why.
I'm developing the insert method of a btree. Below is the code of insert()
void insertar(btree* r, int dato){
int pos=0;
btree* encontrado= buscar(&*r, dato, 0); //buscar() searches if dato already exists
if (encontrado==NULL)
printf(" data already exists");
else
if (encontrado!=NULL){ //ERROR! why??
pos=buscar_nodo(&(*r), dato); //tells me in which position I have to insert the new data
}
}
buscar() returns NULL if the data already exists, else returns pointer of the leaf.
I know the error appears when encontrado!=NULL, but why?
Is there other way to evaluate if a pointer of structure is NULL?
help please! :'(