+ 1

Can we use void main?

29th Jul 2016, 9:35 AM
Tara Bisht
Tara Bisht - avatar
5 Respostas
+ 3
on the website of the author of c++ it's said in the FAQ that void main is not c++. So the best is to avoid it, even if some compilers allow that, it is not standard... A program should return 0 when everything gas been done with success and an other int value to refer an error code when something got wrong. source : http://www.stroustrup.com/bs_faq2.html#void-main
30th Jul 2016, 8:34 AM
Dorian
+ 2
You can but not here. To be honest, you shouldn't. So it's not *perfectly* fine. It's fine from a formal perspective as some compilers accept it. Still, I would consider this a bad practice in any real-life software.
29th Jul 2016, 7:12 PM
Stefan
Stefan - avatar
+ 1
Yes you can, they just used int here because they return 0, void is perfectly fine.
29th Jul 2016, 9:43 AM
Adrian Nyga Marzec
Adrian Nyga Marzec - avatar
+ 1
yes
29th Jul 2016, 12:33 PM
mounika
mounika - avatar
0
yes
29th Jul 2016, 2:29 PM
Abbass Awad
Abbass Awad - avatar