So, I have changed my code to this:
Code:
while (k < aSecondSubString.size()-1)
{
//cout << "newString" << k << " is " << newString << endl;
if (aSecondSubString[k] != ' ' && aSecondSubString[k] != '\t' && aSecondSubString[k] != '\n')
{
if (aSecondSubString[k] == '=')
{
stringVectors.push_back(newString);
newString = "";
}
else
newString += aSecondSubString[k];
if (aSecondSubString[k+1] == '\0' || ((aSecondSubString[k+1] == ' ' || aSecondSubString[k+1] == '\t' || aSecondSubString[k+1] == '\n') && newString.length() > 1))
{
stringVectors.push_back(newString);
newString = "";
}
}
k++;
}
If I understand you correctly, then the first stringVectors.push_back(newString); should be pushing "X", and then that will give me access to stringVectors[0], and then it will pass by the "=" and get to "2", which it then will push_back, (into spot stringVectors[0][0] ?), then i will have access to stringVectors[0][0], and then the same to stringVectors[1], and so on. However, at the moment I am getting the error below.
Code:
substr_multidim_vector_test.cc:47: error: no matching function for call to 'std::vector<std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > > >::push_back(std::string&)'
Any ideas? I know it says no matching function call, but I can't figure out what's wrong with that line. Thanks.