bool spelledCorrectly(char* str) {
// for(int i = 0; i < 50; i++) printf("Word at %i: %s\n", i, wordlist[i]);
for(int i = 0; i < 50; i++) {
// printf("Word in list of length %li: %s\nWord to check of length %li: %s\n", strlen(wordlist[i]), wordlist[i], strlen(str), str);
printf("Verbose list word: ");
printStringVerbose(wordlist[i]);
printf("Verbose input word: ");
printStringVerbose(str);
if(!strcmp(str, wordlist[i])) return true;
}
return false;
}
I was finding that my string in the "wordlist" (basically a dictionary read from a file) is always 1 character longer than the words that are passed in by the user. I wrote a function printStringVerbose() that will print out \0 and \n visibly, and when doing so, I get a very odd result.