+ 1

Why some of the compiler showing error when we write void main() in c++?

8th Sep 2017, 4:34 AM
jemee
jemee - avatar
5 Answers
+ 9
Ah, I was about to post the link but @Jay did it. Yes, void return type for main() has never been a part of the standard, and will never be.
8th Sep 2017, 5:00 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
@manual: it is not even valid c according to the standard
8th Sep 2017, 4:54 AM
jay
jay - avatar
+ 6
it is not considered valid c++. here is what the creator of c++ has to say on the matter: http://www.stroustrup.com/bs_faq2.html#void-main
8th Sep 2017, 4:51 AM
jay
jay - avatar
+ 3
just use int main void main is for C code with no return value.
8th Sep 2017, 4:52 AM
Manual
Manual - avatar
+ 3
@Jay It makes sense, void main did not seem very useful to me, in C code.
8th Sep 2017, 4:58 AM
Manual
Manual - avatar