Can anyone help me with what is different between int main()
and int main(void)
?
Asked
Active
Viewed 118 times
2 Answers
2
Using (void)
as the single parameter in a C++ function is exactly equivalent to using ()
.
Although, stylistically (void)
is to be discouraged.

Bathsheba
- 231,907
- 34
- 361
- 483
-
Do we really need to answer such an obvious dupe? – NathanOliver Apr 04 '16 at 15:26
0
In C++, there is no difference. The difference only arises in C, where not explicitly mentioning void
in the parameter list allows the function to be called with any number of parameters, while the second version only allows exactly 0 parameters.

R_Kapp
- 2,818
- 1
- 18
- 32