Whats wrong with code that uses void main()?
The following code is not usually considered correct: // A: main should not return a void void main() { /* …Whatever… */ } // AA: This is just the same as A: void main(void) { /* …Whatever… */ } The problem is that this code declares main to return a void and that’s just no good for a strictly conforming program. Neither is this: // B: implicit int not allowed in C++ or C99 main() { /* …Whatever… */ } The problem with code example B is that it’s declaring main to return nothing. But not declaring a function’s return value is an error in C++, whether the function is main or not. In C99, the October 1999 revision to Standard C, not declaring a function’s return value is also an error (in the previous version of Standard C an implicit int was assumed as the return value if a function was declared/defined without a return value). But the usual requirement of both Standard C++ and Standard C is that main should be declared to return an int. In other words, this is an acceptable