此函数中某处存在问题,不幸的是编译器没有说明问题所在。程序停止工作,必须关闭。
我是 C++ 的初学者,所以我可能做过一些愚蠢的事情,但我不知道是什么。
我会很感激任何帮助。
vector< vector<string> >gsiread16::make_section(vector<string> blocks) {
string code;
string code2;
vector<string> section;
vector< vector<string> > sections;
for ( int i = 0; i < blocks.size(); i++) {
code = blocks[ i ].substr(0,3);
if( code == "*41" ) {
code2 = blocks[ i+1 ].substr(0,3);
if( code2 != "*11" ) continue;
int index = i +1;
while(code2 == "*11" ) {
section.push_back( blocks[ index ] );
index++;
}
sections.push_back(section);
section.clear();
i = index - 1;
} else continue;
}
return sections;
最佳答案
> while(code2 == "*11" ) {
> section.push_back( blocks[ index ] );
> index++; }
永远无法通过...
i = index - 1;
可能以无限循环结束
关于c++ - 调用函数时程序停止工作。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19315645/