hangman- game doesnt stop with correct answer

May 24, 2015 at 5:04pm
Hangman game, objective programming.
The game doesn't stop even if the answer is correct ("while" loop works until guesses number reach maximum). In the beginning I thought it's a problem with vector to string conversion but it seems it's not that,
that's why I post link to the whole code here:
http://pastebin.com/a34jfGBi

Please, suggest what to change in order to make the game work properly

Thank you!
May 24, 2015 at 5:57pm
It's a bit hard to read the code because I don't understand the language but I found something that's not right.

1
2
3
4
5
6
7
8
vector<int> miejsca;
for (unsigned int i = 0; i <= wyraz.size(); i++)
{
	if (litera == wyraz[i])
	{
		miejsca.push_back(i);
	}
}

wyraz[i] is out of bounds when i == wyraz.size().
Last edited on May 24, 2015 at 5:57pm
Topic archived. No new replies allowed.