Difference between void main and int main?

Kredns picture Kredns · Mar 12, 2009 · Viewed 68.6k times · Source

Does it matter which way I declare my C++ programs?

Answer

Alan picture Alan · Mar 12, 2009

The difference is one is the correct way to define main, and the other is not.

And yes, it does matter. Either

int main(int argc, char** argv)

or

int main()

are the proper definition of your main per the C++ spec.

void main(int argc, char** argv)

is not and was, IIRC, a perversity that came with older Microsoft's C++ compilers.

https://isocpp.org/wiki/faq/newbie#main-returns-int