I saw a member asking about a game like 'Boggle', and thought that sounded like a nice project to write. I made a struct to hold the words in a dictionary..
(370,100 words in total)
1 2 3 4
struct Dictionary_Words
{
string word;
};
I have the game where it checks the Boggle grid and can find the word, or group of letters, you input. That works fine. But, I can't find a way to compare the word entered with a word in the dictionary.
Search_Word is a string
word_list[z].word is a string
if(In_Grid)
{
// My info to show the word was found in grid
cout << "Found the word " << Search_Word << ".." << endl;
In_Dictionary = false; // bool
int size = word_list.size(); // struct dictionary
for(z=0; z < size;z++)
{
gotoXY(5,38);
cout << "Checking word #" << word_list[z].word << " ";
// Below says a match of 'a' is found NO MATTER what word I entered
if(Search_Word.compare(word_list[z].word))
{
gotoXY(5,39);
cout << "Found word in the dictionary";
z = size+1;
In_Dictionary = true;
}
}
else
cout << "That was NOT a word found in the dictionary.." << endl;
How can I compare the two strings without having to resort to convert them to chars??
Thank you for your answer. I did forget to put in the '== 0', and now it does find the word in the list of dictionary words. I did have to first change all the words to uppercase in the word list, but that was an easy conversion. Thanks again.