goto in function

Hi please can be goto used in function, but with reference in main? And if yes how the source should look like?
for ex.

void func(int a);
int x;

int main(){
.
.
.
func(x);
.
.
.
skip:
.
.
.
}

void func(int a);
.
.
.{
GOTO SKIP;
}
No.

You should avoid goto anyway, as it can make code very confusing and hard to follow (and therefore bug prone).
And is there any order that stop movement of main function, but is used in another function, that turns the programme off as return 0 but is declared in another function not in main?
exit(1); will end your program from any function (with an exit code of 1).

To use it, you have to #include <cstdlib>

Reference:
http://www.cplusplus.com/reference/cstdlib/exit/
Last edited on
Topic archived. No new replies allowed.