File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes C / C++ and the fly likes Return 0 in main() function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Return 0 in main() function" Watch "Return 0 in main() function" New topic
Author

Return 0 in main() function

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If I use return 0; in main function( and define in as int main() ,of course)then where does the control is transferred after execution of that last line in the code??Isn't it absurd to use return 0 in main()..???
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 988
    
    1
Anonymous wrote:If I use return 0; in main function( and define in as int main() ,of course)then where does the control is transferred after execution of that last line in the code??Isn't it absurd to use return 0 in main()..???


The return value from the main function/method is returned to the operating system. Returning a 0 indicates no errors, by convention. IF I RECALL CORRECTLY, in bash (a Unix shell) the return value of a program is assigned to the $? variable:

myProg arg1 arg2
echo myProg returned $?

DOS/Windows does a similar thing with the %ERRORLEVEL%

myProg
echo myProg returned %ERRORLEVEL%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Return 0 in main() function
 
Similar Threads
Oracle select in view question (String function ? )
How to send the contents of a screen in an email
Getting a return value from a function and using it another fuction
why there is a compile time error
Exit Sub in java?