这个 if 语句不起作用。
谁能告诉我为什么下面的代码不起作用,并帮助我修复?
i=0;
while(1)
{
if(counter2 < storeanother[0].size())
break;
int j=0;
while(1)
{
if(j < handler)
break;
outputFile2 << storeanother[0][counter2] << " + " << storeanother[1][counter2] << " = " << z80[i].get(j) << endl;
counter2+=1;
j++;
}
i++;
}
outputFile2.close();
最佳答案
你反转条件
for (init; cond, post) { body;}
相当于
init;
while (true) {
if (!cond) { // and not simply cond
break;
}
body;
post;
}
甚至
init;
while (cond) {
body;
post;
}
所以
if(counter2 < storeanother[0].size())
break;
应该是
if (counter2 >= storeanother[0].size())
break;
和另一个循环类似。
关于c++ - 尝试 If 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34331289/