(I'll check when I'm no longer on a phone unless someone beats me to it!)
Further, to confuse the issue, you don't have to explicitly return anything from main even if it's defined as 'int main'.
(I'll check when I'm no longer on a phone unless someone beats me to it!)
Further, to confuse the issue, you don't have to explicitly return anything from main even if it's defined as 'int main'.
It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main: int main() { / ... / } and int main(int argc, char* argv[]) { / ... / }
In the latter form argc shall be the number of arguments passed to the program from the environment in which the program is run.If argc is nonzero these arguments shall be supplied in argv[0] through argv[argc-1] as pointers to the initial characters of null-terminated multibyte strings
---
No version of the C or C++ specs have said void main is acceptable, (apart from the implementation-defined optional main for non-hosted systems). However, most compilers have it as a language-extension.
A return statement in main was compulsory until C99, where the compiler was to assume return 0, if not specified. Some compilers had that behaviour already, however.