c++: vectorof structs
<p>i am using an empty vector of structs.</p>

<p>now, when i am entering data to one of the struct members, does it change the size of the vector?</p>

<p>if yes, how should i initialize the iterator?
i have a runtime error, and my guess is that my iterator is invalid.</p>

<p>some relevant code:</p>

<pre><code>   struct wordstype
{
    string word;
    int counter_same;
    int counter_contained;
    int counter_same1;
};
 std::vector&lt;wordstype&gt;::iterator iv=vec1.begin();
string temp_str;
string::iterator is=str1.begin();

while (is!=str1.end())
{
    if (((*is)!='-')&amp;&amp;((*is)!='.')&amp;&amp;((*is)!=',')&amp;&amp;((*is)!=';')&amp;&amp;((*is)!='?')&amp;&amp;((*is)!='!')&amp;&amp;((*is)!=':'))
    {
        temp_str.push_back(*is);
        ++is;
    }
    else
    {        
        (*iv).word=temp_str;
        ++iv;
        str1.erase(is);
        temp_str.clear();
    }
}
</code></pre>
