View Single Post
Old Nov 15th, 2006, 3:42 PM   #7
aznballerlee
Hobbyist Programmer
 
Join Date: Nov 2006
Posts: 111
Rep Power: 3 aznballerlee is on a distinguished road
Hmm okay:

1. Your loop seems to be checking for a match on any letter in any position. If this is how it is supposed to work, then fish should get a score of 1, because of the "s"


2. Your loops for the letter checking should not go to MAXWORDLENGTH, as that is reading past the end of shorter words. The characters after the zero terminator at end of the word (e.g. fish) may be random. Your loop should check to see if the you have reached the end of the word you are looking for (e.g. check guess[z] != 0 in the "z" for loop


Yeah, I added to check for the the null character here:

if ((guess[z] == wordList[wordnum][j]) && (boolArray[j] == false)
&& (guess[z] != '\0'))   
{	
	boolArray [j] = true;
	break;                             
}

3. I don't know what the i loop is for - you break out of it immediately in either case in the first if test, so it doesn't look like it should be there at all.

The i loop is to check if the guess is exactly correct to the secret word. If it is, then I break out of the function. (end that round)
aznballerlee is offline   Reply With Quote