I’m trying to store strings that I read from a file in a std::vector but I’m getting a weird error…
So I have the container:
std::vector<std::string> m_Strings;
Then I read the string from a stream:
ifstream inStream;
char word[100];
//[...]
inStream >> word;
m_Strings.push_back(word);
Even though the vector is empty, when I insert the first string the vector resizes to hold 8 strings, the string at index 0 containing random characters, at index 1 containing the correct word, and the other indices containing invalid pointers…
Any idea of what might cause this?
EDIT: In this case I’m reading the string “DIRECTIONAL_LIGHT” so it fits in the char word[100]
Just changed
char word[100];tostd::string word;and the error disappeared.