Hi,
I am kind of new to C++ and really stuck with a problem. Here I am trying to parse a string and after comparing to a pre-declared array save the tokens in a vector of vectors. It is giving a number of errors and I'm not sure what to change since I am using char* tokens in a another function as well. Could someone please tell me what is the best way to go about doing this and what changes i should make. Here is the function that is giving errors.
void parse(std::vector<char*>* tokens)
{
std::vector<string> entity;
int i=0, j=0, row=0;
bool ent=false;
//Initialisation of the program relationship model
entity[0] = "stmt";
entity[1] = "assign";
entity[2] = "while";
entity[3] = "if";
entity[4] = "constant";
entity[5] = "prog_line";
entity[6] = "call";
vector< vector<string> > matrix;
/*for(int i=0; i<7; i++){
matrix.push_back(vector <string>());
matrix[i].push_back("xyz");
}
cout << matrix[2][0]; */
//compare the tokens to the array entity
for(i=0; i<tokens.size(); i++)
{
for(j=0; j<7; j++)
{
matrix.push_back(vector <string>());
if(tokens[i] == entity[j])
do{
i++;
if(tokens[i] != "," || tokens[i] != ";")
matrix[row][j] = tokens[i];
}while(tokens[i] != ";");
}
}
}