how to exit nested loops
问题 i have something like while(playAgain==true) { cout<<"new game"<<endl; //i know 'using namespace std;' is looked down upon while(playerCard!=21) { *statements* if(decision=='n') { break } ... } } but that break only breaks out of the first while loop when I want to break out of both of the loops 回答1: Don't cook spaghetti and extract your loops into the function: void foo(...) { while (...) { /* some code... */ while (...) { if ( /* this loop should stop */ ) break; if ( /* both loops should