コードで「string not dereferencable」エラーが発生します。これは、インターネット上のどこかから逐語的にコピーされたものです。アプリケーションはリリース モード (VS 2010) で完全にコンパイルされますが、デバッグ モードではエラーが発生し続けます。* で文字列を分割し、各単語をベクトルに保存する必要があります。誰にもアイデアはありますか?比較の (string::npos != found) 部分が本当に気に入らないようです。
string newString = "Something*NotCool";
size_t found = newString.find_first_of("+*-/%()");
size_t lastPos = 0;
//while (found != newString.length)
while (string::npos != found || string::npos != lastPos)
{
if (found >= newString.length()) break;
if (found == lastPos)
{
lastPos = found+1;
found = newString.find_first_of("+*-/()", found+1);
}
string temp (newString,lastPos,found);
temp.assign(newString, lastPos, found-lastPos);
strings.push_back(temp);
lastPos = found+1;
found = newString.find_first_of("+*-/()", found + 1);
}
あなたの助けに感謝します!!!