+ 2
Fundamental Question on C
What is the difference between int main() and int main(void)
4 Answers
+ 9
In C++, no difference. Void in parameters is a relic from C.
In C, when we do int main(), nothing is specified regarding the parameters. int main(void), on the other hand, tells the compiler that this main function takes no arguments.
https://stackoverflow.com/questions/5587207/why-put-void-in-params
https://stackoverflow.com/questions/693788/is-it-better-to-use-c-void-arguments-void-foovoid-or-not-void-foo
+ 4
@Mohd Zaki
The int at the beginning of int main() and int main(void) is what makes it return an integer. The parameters make no difference there.
+ 3
in plain c
int main(void); is a function decleration that takes no arguments
int main(); is a prototype that can take yet unspecified number of arguments
in c++ there is no difference.
Further i dont see any use in prototyping the main function...
- 6
int main() will return a int value but int main(void) do not return anything.