[Tutor] c++::return
Alan Gauld
alan.gauld at btinternet.com
Tue Mar 18 23:09:12 CET 2008
"elis aeris" <hunter92383 at gmail.com> wrote
> what do I do if i want the program/function to end?
>
> in c++ of
>
> int main(){}
>
> I do a return 0;
Actually you don;t. In your e4xample yuou just have empty
braces and that will end just fine! Similarly in Python it will
just silently drop off the end of the code.
However if you want to return a value to the OS other
than 0 you can use the exit function from the sys module.
(Or raise a SystemExit exception with an argument of
the required error code)
sys.exit() is explained in the Simple Sequences topic
of my tutorial.
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list