Reading from a file of names, I'm trying to put those name into a binary search tree. But for some reason when I read the file, I am starting with a random junk file node:
TreeNode* read_from_file(const char* file){
File *fp = fopen(file,"r");
char buffer[MAX_NAME_LEN];
TreeNode *t = NULL;
t = insert(t,buffer); //insert is just your standard function for creating a binary tree
while(!feof(fp)){
fscanf(fp,"%s",buffer);
insert(t,buffer);
}
return t;
fclose(fp);
}
When I then print out the tree I am getting a seemingly random node in my list such as '{ or ĂFĂ> along with the name nodes when the inputed file only has names like bob matt and nick.