+ 1

Can void main be used in place of int

16th Apr 2017, 5:23 PM
Vishwas Mishra
Vishwas Mishra - avatar
4 Antworten
+ 6
Some compilers will allow it, but it goes against the C++ standards, so you should never do it. Your main function should always return an integer. http://www.stroustrup.com/bs_faq2.html#void-main
16th Apr 2017, 6:48 PM
Squidy
Squidy - avatar
+ 1
I dont think so as a compiler will insert return int if it is left out of your code (not 100% on this one though)
16th Apr 2017, 5:35 PM
Jason Hoffman
Jason Hoffman - avatar
0
What for? The return of main is used to send signals to the caller (OS). It is a way for your program to communicate with the system, for example, to report errors. Just because most people don't understand it, it does not mean it is useless.
17th Apr 2017, 3:53 AM
Denis Felipe
Denis Felipe - avatar