Code:
if (temp->left != 0 && temp->name <= name)
if (temp->left == 0)
{
temp->left = newNode;
break;
}
else // move to subtree
temp = temp->left;
else if (name < temp->name)
if (temp->right == 0)
{
temp->right = newNode;
break;
}
else // move to subtree
temp = temp->right;
else if(name > temp->name)
temp = temp->right;
//else if (name == temp->name)
return;
}
I would add curly brackets around every if/else if/else block here to ensure it is doing what you think/want it to do. Its incredibly difficult to read and trace this manually. In addition, its good practice to always have these brackets around even 1 line if/whatever blocks of code.
I havent looked at all of the code, but heres something probably isnt what you want
Code:
if (temp->left != 0 && temp->name <= name)
if (temp->left == 0)
The inner if statement checks that the left is null, but its guaranteed to not be null, because the outer if checked if it was != 0. I would look around in your code for other similar logic errors like this, in addition to adding braces around every block, even for 1 line blocks. For starters, at least.