I'm currently working on a project similar to that of text twist.
I have a dictionary txt file which I stored into an array.
I then have user input a guess, then compare the guess to the dictionary array using a for loop. Somewhere along the lines of this:
string guess;
cin >> guess;
dictionary(guess);
void dictionary(string guessF, dictionaryarray[])
{
bool check = false;
for(i = 0; i < 10000; i++)
{
if(guessF == dictionaryarray[i])
{
cout<<"correct!";
check = true;
break;
}
}
if(check == false)
{
cout<<"Wrong!";
}
Thats just the quick gist of it (I also added parameters to check if the guess is < 3 char or guess > 6). And it works, when I input a word that isn't in the dictionary, or less than 3 or more than 6 characters, it couts the correct lines. However, if I input ANYTHING that is in the dictionary.txt, it returns correct.
So my question is how do I compare the given word, say givenword = "monkey";
in the dictionary there is say for example "key" , "money", "donkey", "monk";
I want to be able to run a function that goes through the dictionary and pulls out "key", "money", and "monk" as those are words that can be formed and stores them in a 3rd array.
and ignores "donkey" because there is no "d" in givenword.
I hope I made some sense in my question =X
Much appreciated.