私は非常に奇妙なことに遭遇しました。私が問題を抱えているコードは次のとおりです。
int stringPos;
int found1;
while (stringPos < 1);
{
//start searching inString for framen starting at foundn and record
found1 = inString.find(frame1, found1);
cout << found1 << endl;
//if return is a number, push back foundn to a vector
if (found1 != -1)
{
foundPositions.push_back(found1);
}
//if return is npos, then break the loop
else
{
stringPos=1;
}
//add 1 to foundn so that the search would continue from where the
//search ended last
found1+=1;
}
cout << found1 << endl;
奇妙なことは、行の下に置くとfound1 = inString.find(frame1, found1);
、ループが適切に実行されることです。ただし、持っていないとcout << found1 << endl;
無限ループに入ります...
助言がありますか?ありがとう!