From the source code below, Is there a way to get out of the overlapped repeat door at once using break?
int main(){
for(int i=0; i<A; i++){
//...
for (int j=0 ; j<B; j++) {
//...
for (int k=0; k<C; k++) {
if (D) {
break; // here
}
//...
}
//...
}
//...
}
}
In Java or other languages, you can name loop and solve it C++ doesn't have that capability.
It can't be a break
You can solve it by writing goto
or by creating flag
.
The code below is to create endflag
to exit the repeated statement overlapped with conditional statements
int main(){
bool endflag = 0;
for(int i=0; i<A; i++)
{
for (int j=0 ; j<B; j++)
{
if (C) {
endflag = 1;
break;
}
}
if (endflag) {
break;
}
}
}
593 Uncaught (inpromise) Error on Electron: An object could not be cloned
567 Understanding How to Configure Google API Key
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
865 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.