終了条件が一致すると、なぜこのwhileループが停止しないのか理解できませんか?
アイデアは、ユーザーが5桁の整数を入力し、入力プロセスを終了するために他の何かを入力できるというものです。だが
bool noerror(true);
int n(0),part2temp;
vector<int> part2;
while(noerror){
cout << "Please enter the 5 integer (x to stop)" << endl;
cin >> part2temp;
part2.push_back(part2temp);
n++;
if (cin.fail()||part2temp>99999||part2temp<10000){
cout << "End condition matched" << endl;
cin.clear();
cin.ignore(10);
noerror=(false);
}
}
cout << "escaped loop" << part2[n] << endl;
たとえば、xを入力すると、ループのIF部分から画面に出力が表示されますが、何らかの理由でbool値を変更してもループは終了せず、「escapedloop」というテキストが画面に表示されません。
誰かが私が間違っていることを教えてもらえますか?