Comparing two strings
I am writing a binry tree and need to compare two strings to see if their are more nodes in the current node.
Here is the code so far. Each node has "information" inside it which it is a string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
if(current->left == NULL)
{
if(parent->info.compare( current->info) > 0)
parent->left = current->right;
else
parent->right = current->right;
}
else if(current->right == NULL)
{
if(parent->info.compare( current->info) < 0)
parent->left = current->left;
else
parent->right = current->left;
}
|
Any help is mostly appreciated
If string is a c-string (char array), see strcmp,
if it is an std::string, you can use ==.
Yer it is a std::string but still the comparison does not work
What's your code?
Topic archived. No new replies allowed.