I have encountered something very strange. The code I am having trouble with is:
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;
}
The strange thing is that when I put cout << found1 << endl;
below the line found1 = inString.find(frame1, found1);
the loop executes properly. However, if I don't have the cout << found1 << endl;
it enters an infinite loop...
Any suggestions? THANKS!