Hi all,
When the user enters a word, isKnownWord() checks whether the word is in the dictionary but even when I enter a word which I know is in the dictionary, into the terminal, it always outputs no! Can somebody please explain why it is doing this?
isKnownWord in sc class
bool isKnownWord(char* aWord) {
struct wordRecord* wordRecPtr = wordList;
bool found=false;
while (!found && wordRecPtr) {
if (strcmp(aWord, wordRecPtr->word)==0) found=true;
else wordRecPtr=wordRecPtr->next;
}
return found;
};
main method snippet:
char* words[] = {(char*)"hello", (char*)"Womble", (char*)"goodbye"};
char inputWord[80];
caseSensitiveSpellChecker sc;
//caseSensitiveSpellChecker * sc = new caseSensitiveSpellChecker();
for (int i=0; i<sizeof(words)/sizeof(char*); i++) sc.addWord(words[i]);
printf("Enter word ('END' to end): ");
scanf("%s", inputWord);
while (strcmp(inputWord, "END")) {
if (sc.isKnownWord(inputWord)) printf("yes\n");
else printf("no\n");
printf("Enter word ('END' to end): ");
scanf("%s", inputWord);
}
Aphrodite