Re: C main() function
It is helpful to recognize the distinction between declaring a function with "foo(void)" versus with "foo()". The former explicitly forbids any arguments from being passed to the function; the latter merely indicates that nothing is known about the arguments. A call with arguments would not necessarily fail, and is typically permitted by the compiler (though warnings may be generated).
'main' is unique in the C language in that it can have either no or two arguments and still be compliant with the standard (ANSI). Some compilers allow more than two arguments (MS C has three, and others permit variable-length lists of arguments), but these are non-compliant. Leaving out 'void' is not equivalent to having either zero or two arguments, so it is likewise non-compliant.
If your program is intended to be maximally portable, it should comply with the ANSI standard. This means using 'void' when no arguments are expected.
"We visited sixty-six islands and landed eighty-one times, wading, swimming (to shore). Most of the people were friendly and delightful; only two arrows shot at us, and only one went near -- So much for savages!" - J.C. Patterson
Bookmarks