Click here to Skip to main content
15,892,005 members

Response to: escaping a large function

Revision 1
easy, use another variable which can store the value of your desired variable.
use label on your specific point and use goto statemnt to get there

C++
int x;
for (;;)
for(;;)
for(;;)
{
 int y=123;
 if(y==123){ x=y; goto mylabel;}
}

mylabel:
cout << x;


goto is not a good approach but has its advantages, when you dont want to use return statement and do want make a jump, just that goto can jump anywhere in a function which makes it dangerous....
Posted 5-Nov-12 6:03am by psychic6000.
Tags: