小编kto*_*yev的帖子

如果cout丢失,循环进入无限循环

我遇到了一些非常奇怪的事情.我遇到问题的代码是:

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;
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我放在线cout << …

c++ string infinite-loop while-loop endl

0
推荐指数
1
解决办法
122
查看次数

标签 统计

c++ ×1

endl ×1

infinite-loop ×1

string ×1

while-loop ×1