Quote Originally Posted by nbaztec View Post
She says:
1. Why the hell use int main() when void main() works fine.
It does?
Code:
void main()
{
}
Code:
Thank you for testing your code with Comeau C/C++!
Tell others about http://www.comeaucomputing.com/tryitout ! 

Your Comeau C/C++ test results are as follows: 


Comeau C/C++ 4.3.10.1 (Oct  6 2008 11:28:09) for ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing.  All rights reserved.
MODE:strict errors C++ C++0x_extensions

"ComeauTest.c", line 1: error: return type of function "main" must be "int"
	So use int main() OR int main(int argc, char *argv[])
  void main()
       ^

1 error detected in the compilation of "ComeauTest.c".

In strict mode, with -tused, Compile failed
Also, technically, it need not work fine.

There are some older compilers out there that will produce code that will fail if the wrong return type for main() is used (unfortunately, these compilers do not check if you have the wrong return type for main). The reason for this is that you, the programmer, is indicating to the compiler one thing (that main doesn't return anything), but in reality, main() does return something. So code is generated that implies that a return is not done, but a return is done.

So what do you have? You have a program that either produces undefined behaviour on exit, or some other issue -- usually return/stack related issues.

The correct return type for main() is int. There is no ambiguity about it.

Here is an older 'C' link:

http://users.aber.ac.uk/auj/voidmain.shtml

Regards,

Paul McKenzie