Hi,
My problem relates to the following code, which is part of a function in a chat bot program. The function takes the argument read_wd, which is a std::string. Basically this is just a word input by the user. All I'm trying to do is add the word into the known_words multimap, along with it's type (nouns, verbs etc.).
The problem is, the following doesn't work. If I later try to access the word in known_words by it's type, I can't find it in there.
Code:
char word_type1[10] = "";
cin >> word_type1;
known_words.insert ( pair<string, const char*>(read_wd, word_type1) );
On the other hand, if I do this:
Code:
known_words.insert ( pair<string, const char*>(read_wd, "nouns") );
Then it works OK. Does anyone know why the first bit of code doesn't work? I thought it was something to do with the length of what's in word_type1, but if I output word_type1 before trying to use it with the insert stuff, it comes out as "nouns". So I don't understand why it won't work in there.
Thanks for the help.