私は構造体の空のベクトルを使用しています。
構造体メンバーの1つにデータを入力すると、ベクトルのサイズが変更されますか?
はいの場合、イテレータをどのように初期化する必要がありますか?ランタイムエラーが発生しましたが、イテレータが無効であると推測されます。
いくつかの関連コード:
struct wordstype
{
string word;
int counter_same;
int counter_contained;
int counter_same1;
};
std::vector<wordstype>::iterator iv=vec1.begin();
string temp_str;
string::iterator is=str1.begin();
while (is!=str1.end())
{
if (((*is)!='-')&&((*is)!='.')&&((*is)!=',')&&((*is)!=';')&&((*is)!='?')&&((*is)!='!')&&((*is)!=':'))
{
temp_str.push_back(*is);
++is;
}
else
{
(*iv).word=temp_str;
++iv;
str1.erase(is);
temp_str.clear();
}
}