I am having trouble putting values into a 2D vector. I'm trying to put the X into one spot and then have the 2 be in the other. so it will eventually be like this:

vector[0] = X

vector[0][0] = 2

vector[1] = Y

vector[1][0] = 4

or does it have to be like this?

vector[0][0] = X

vector[0][1] = 2

vector[1][0] = Y

vector[1][1] = 4

anyways, here's the code if someone could help me.

Code:#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector< vector<string> > stringVectors; aSecondSubString = " X=2 Y=4"; unsigned k = 0; string newString; while (aSecondSubString[k] != '\0') { //cout << "newString" << k << " is " << newString << endl; if (aSecondSubString[k] != ' ' && aSecondSubString[k] != '\t' && aSecondSubString[k] != '\n') { if (aSecondSubString[k] == '=') { stringVectors[stringVectors.size()].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[stringVectors.size()][0].push_back(newString); newString = ""; } } k++; } unsigned j; for (j = 0; j < stringVectors.size(); j++) { //cout << j << ": " << "\"" << stringVectors[j] << "\"" << "Value: \"" << stringVectors[j][0] << "\"" << endl; } return 0; }