I am receiving a segmentation fault while searching through a binary tree for a match. It does not give me a segmentation fault if a match is found but if it does not find anything it isn't finishing properly. Could someone point me in the right direction? What am i doing wrong.
void search() {
char temp,temp1[15];
struct node *s=root;
int i=0;
do{
printf("Enter Name To Be Searched\n");
scanf("%s",temp1);
getchar();
i=0;
s=root;
while(s!=NULL && i==0){
if(strcmp(s->data,temp1)< 0)
s=s->right;
if(strcmp(s->data,temp1)>0)
s=s->left;
if(strcmp(s->data,temp1)==0)
i=1;
}
if(i==0)
printf("Element Not Found\n");
else
printf("Element Found\n");
printf("Enter More Elements[Y/N]:\n");
temp=getchar();
printf("%c", temp);
}while(temp=='y');
}