The Reasons behind to return an int from main()

28/07/2008 14:54

On many operating systems, the value returned by main() is used to return an exit status to the environment. On Unix, MS-DOS, and Windows systems, the low eight bits of the value returned by main() is passed to the command shell or calling program. This is often used to change the course of a program, batch file, or shell script.

Many compilers will refuse to compile a source code file containing a definition of main() which does not return an int.

On some platforms a program starting with void main() may crash on startup, or when it ends.

A program which contains a main() function that is not defined to return an int is just plain not real C.

So please don't use void main().


sahaya.webnode.comĀ© 2008 All rights reserved.

Make a free websiteWebnode