Using VS 2012.
I was making hangman. Anyway, I had a function to get a std::string that was the same length as the current word being guessed, but filled with underscores. (as in, blanks).
The function:
std::string getBlankWord(std::vector<std::string> words, int currentWordIndex)
{
return std::string(words[currentWordIndex], '_');
}
The line it is called on:
currentGuessingString = getBlankWord(words, index);
words is an std::vector, index is an int. words.size() = 22, and index = 0, so I don't know how calling, in this case, words[0] could be the culprit. Anyway, something on this line throws std::out_of_range exception, but I cannot find it.
Thanks.
std::string(const std::string&, int)constructor O.o It totally exists though: en.cppreference.com/w/cpp/string/basic_string/basic_stringgetBlankWordshould take the vector by const reference:const std::vector<std::string>& words, or else it will copy the whole array each time you call the function :(