I am trying to compare corresponding string indexes one at a time within a nested loop.But I keep getting an error and a outcome I know I am not looking for. Need some assistance please?
int main() {
setConsoleExitProgramOnClose(true);
setConsolePrintExceptions(true);
////////////////////////////////////////////////////////////
// A function that produces all the possible outcomes of only one letter being
// changed
Lexicon english("EnglishWords.dat");
string startWord;
string finishWord;
startWord = getLine("Enter a legal word (must be lowercase): ");
finishWord = getLine("Enter another legal word(must be lowercase): ");
for(int i = 0; i <= startWord.length(); i++) {
string copyWord = startWord;
for(int j = 0; j <= finishWord.length(); j++) {
for(char ch = 'a'; ch <= 'z'; ch++) {
copyWord[i] = ch; // new string from startWord that has one letter change
////////////////////////////////////////////////////////////
getLine("Program finished. Press ENTER to close window(s)");
closeConsoleAndExit();
return 0;
}
Note that one of my startWord string changes by one letter. Trying to return the modified string that has the matching corresponding character with the finishWord string if any.