C++: Redirect code to certain position -


i new c++.

how can "redirect" code position?

basically, should put instead of comments lines here:

if ( n>1 ) {   // should here make code start beginning?  } else {   // should here make code start point? } 

i understand c++ not scripting language, in case code written script, how can make redirect it?

thank you

a goto command want it's frowned on in polite circles :-)

it has place possibly better off learning structured programming techniques since overuse of goto tends lead call spaghetti code, hard understand, follow , debug.

if mandate make minimal changes code sounds may badly written, goto may best solution:

try_again: n = try_something(); if (n > 1)     goto try_again; 

with structured programming, have like:

n = try_something(); while (n > 1)     n = try_something(); 

you may not see much of difference between 2 cases that's because it's simple. if end labels , goto statements separated, or forty-two different labels, you'll beg structured version.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -