I know there are lots of questions with similar titles here, but no one seems to work for me. I have this kind of txt file:
tree pine
color blue
food pizza
and I want to store the items in a char* 2d vector, such as
vector<vector<char*>> data;
..
..
data[0][0] = tree
data[0][1] = pine
data[1][1] = blue
ecc
This is the code:
// parse configuration file
bool Configuration::fileParser(char* filename)
{
vector<vector<char*>> data;
fstream fin("data/setup.txt");
string line;
while (fin && getline(fin, line))
{
vector<char*> confLine;
char* word = NULL;
stringstream ss(line);
while (ss && ss >> word)
{
confLine.push_back(word);
}
data.push_back(confLine);
}
storeData(data);
return 0;
}
But when I run the code an exception is thrown.
Exception thrown: write access violation.
How can I solve this problem? Thank you