is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1 or the ISO C standard 22.214.171.124.1. A conforming implementation accepts
A conforming implementation may provide more versions of main(), but they must all have return type int. The int returned by main() is a way for a program to return a value to “the system” that invokes it. On systems that doesn’t provide such a facility the return value is ignored, but that doesn’t make “void main()” legal C++ or legal C. Even if your compiler accepts “void main()” avoid it, or risk being considered ignorant by C and C++ programmers.
In C++, main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution. For example:
Note also that neither ISO C++ nor C99 allows you to leave the type out of a declaration. That is, in contrast to C89 and ARM C++ ,”int” is not assumed where a type is missing in a declaration. Consequently:
is an error because the return type of main() is missing.
To summarize above, it is never a good idea to use “void main()” or just “main()” as it doesn’t confirm standards. It may be allowed by some compilers though.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- int (1 sign bit + 31 data bits) keyword in C
- Basic Input / Output in C++
- C++ Data Types
- C/C++ Preprocessors
- Writing first C++ program : Hello World example
- Setting up C++ Development Environment
- Variables and Keywords in C
- Functions in C/C++
- Interesting Facts about Macros and Preprocessors in C
- C Language Introduction
- C Programming Language Standard
- Difference between "int main()" and "int main(void)" in C/C++?
- Virtual Functions and Runtime Polymorphism in C++ | Set 1 (Introduction)
- Can main() be overloaded in C++?
- How are variables scoped in C - Static or Dynamic?