Heres the problem... Program almost works.. if i cut out the playAgain function the code runs..however say I enter the word "cat" as the word to guess. First guess enter 'c' it shows up and displays properly. second guess 'a' same result third guess 't' now program only displays 'c' and 't' entered and will not give a win untill 'a' is entered a second time. I hope this is clear enough and someone can point out what I am misunderstanding. Thank YOU!
You're main problem is that you have not allocated memory for the knownLetters array so it's over-writing bad memory spaces and causing your bug. You also need to work on code formatting to make your code more readable.
Consider using this instead:
1 2 3 4 5
string knownLetters = "";
// Then in main
word = secretWord; //assigns secretWord to word
knownLetters.assign(word.size(), '\0');
Well, you know that there are 26 letters in the English language, and assuming that this is being run in English... the array would only have to be 26 letters long. So there's no need for having an unallocated array, unless you're allowing the user to enter symbols and such in place of letters. Also, why are you #includ(ing) cmath? You never use any of its specific functions anywhere in the code, so I fail to see why you need it.
@Ispil The number of letters in the alphabet isn't relevant here. He is using the knownLetters array to check which letters have been placed in the correct location when compared to word. This could in theory be an unlimited length array. The problem here is that the OP simply forgot to allocate some memory.