cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
goto in function
goto in function
Nov 30, 2013 at 7:38am UTC
jskrabak
(2)
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;
}
Nov 30, 2013 at 8:23am UTC
Disch
(13742)
No.
You should avoid goto anyway, as it can make code very confusing and hard to follow (and therefore bug prone).
Dec 1, 2013 at 12:08pm UTC
jskrabak
(2)
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?
Dec 1, 2013 at 1:18pm UTC
Disch
(13742)
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
Dec 1, 2013 at 1:19pm UTC
Topic archived. No new replies allowed.