Possible Duplicate:
Standard way to define parameter-less function main() in C
Can I use a declaration definition of function main() in C that looks like:
int main() {}
Yes, I saw that standard says that there are only two guaranteed-supported versions:
int main(void) {}
and
int main(int argc, char* argv[]) {}
But what about empty paratheses? I know that it has another meaning than in C++ (in C, it means that number and types of parameters of this function isn’t known), but I saw really much code in C with this declaration definition of main.
So who’s wrong?
In C, there’s a difference between the declarations
int main();andint main(void);(the former declares a function with an unspecified number of arguments, and the latter is actually called a prototype). However, in the function definition, bothmain()andmain(void)define a function that takes no arguments.The other signature,
main(int, char**), is an alternative form. Conforming implementations must accept either form, but may also accept other implementation-defined signatures formain(). Any given program may of course only contain one single function calledmain.