Link to home
Start Free TrialLog in
Avatar of adr2002
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.substr(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
ASKER CERTIFIED SOLUTION
Avatar of efn
efn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adr2002
adr2002

ASKER

Hmmm, I must have had a typo in the spelling of push_back.  Its working now.  The error message was saying that my struct was not compatible with the operator 'push_back' so I was thinking it was a compatiblility issue, but guess it was just a stupid mistake.  
    Thanks for the help.