adr2002
asked on
how to fill a vector within a struct
Hi,
I am passing a vector<tag> tagList to a function that splits html tag names and their attributes. Since there can be multiple attributes I am using a vector<string> to hold these in my 'tag' struct. I am having trouble filling this struct's inner vector.
In main:
// some code
vector<tag> tagList;
for(vector_size k = 0; k != v.size(); ++k)
splitWords(v[k], tagList);
Other function:
void splitWords(const string& s, vector<tag>& list){
tag record;
//some code to split
if (count == 0)
record.name = s.substr(i, j-i);
else
** record.att.pushback(s.subs tr(i, j-i));
list.push_back(record);
I am getting an error on the line with the '**'. The pushback is not working properly. How can I fill a vector that is inside of a struct?? Thanks very much for any help ahead of time.
-Alex
I am passing a vector<tag> tagList to a function that splits html tag names and their attributes. Since there can be multiple attributes I am using a vector<string> to hold these in my 'tag' struct. I am having trouble filling this struct's inner vector.
In main:
// some code
vector<tag> tagList;
for(vector_size k = 0; k != v.size(); ++k)
splitWords(v[k], tagList);
Other function:
void splitWords(const string& s, vector<tag>& list){
tag record;
//some code to split
if (count == 0)
record.name = s.substr(i, j-i);
else
** record.att.pushback(s.subs
list.push_back(record);
I am getting an error on the line with the '**'. The pushback is not working properly. How can I fill a vector that is inside of a struct?? Thanks very much for any help ahead of time.
-Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help.