C++ hash_multiset for string question

Can I use hash_multiset for storing string values and then searching if the value of another string exists in my set? Below is my program. I am populating hash_multiset with string "mango", "guao". Then when I use find or count on "mango" it is not finding it.

int main()
{
hash_multiset <const char*> hms1;
hash_multiset <const char*> :: const_iterator hms1_RcIter;

hms1.insert("mango");
hms1.insert("guao");
for(hms1_RcIter = hms1.begin(); hms1_RcIter != hms1.end(); hms1_RcIter++)
cout<<*hms1_RcIter<<" ";
int mysize = hms1.size();
cout << "Size is "<< mysize << endl;

mysize = hms1.count("mango");
cout << "Count is "<< mysize << endl;

hms1_RcIter = hms1.find("mango");
if ( hms1_RcIter != hms1.end( ) )
cout << "The element of hash_multiset hms1 with a key of mango is: "
<< *hms1_RcIter << "." << endl;
else
cout << "The hash_multiset hms1 doesn't have an element "
<< "with a key of mango." << endl;

return 0;
}
OUTPUT:

mango guao Size is 2
Count is 0
The hash_multiset hms1 doesn't have an element with a key of mango.
Why would it find it? The original char * value is not going to be the same or have the same hash as the new char * value.

Can you not use std::string for this behavior?
Topic archived. No new replies allowed.