+ 6

Why void main shouldn't be used instead of int main?

Function

23rd Jul 2019, 2:51 PM
Devi Kamaraj..😉
Devi Kamaraj..😉 - avatar
7 ответов
+ 6
In C standard, any return type is valid on compiling, but throws Non-zero code exit for return type other than int and leading unproper close of the program and memory junks. To avoid these problems occuring in C on runtime, when C introduced with classes as C++, C++ standard made strict implementation of int return type for main function... return 0 in main function means the proper closing of the program and cleaning of memory junks... Read all the comments embedded inside the following codes... I also attached usage case of return 0 in main both C and C++ https://code.sololearn.com/cInGdp3Gb67B/?ref=app https://code.sololearn.com/c4Aq38j797c9/?ref=app https://code.sololearn.com/cu6wcmgq3liY/?ref=app https://code.sololearn.com/cO1YCecpbysD/?ref=app https://code.sololearn.com/c5DOHLo1b2qM/?ref=app https://code.sololearn.com/c98qFBVnL32h/?ref=app https://code.sololearn.com/cy21m7mKhPqj/?ref=app https://code.sololearn.com/cAiEXJf8ylZg/?ref=app https://code.sololearn.com/c9047eKO7TwY/?ref=app
14th Dec 2019, 1:11 AM
Ve Sudhakaran
+ 3
Fine. But the return type of all the coding shouldn't be of int type na
17th Aug 2019, 6:07 AM
Devi Kamaraj..😉
Devi Kamaraj..😉 - avatar
+ 3
The same thing I mentioned in my question. Thanks ushasri mavuri.
1st Sep 2019, 9:03 AM
Devi Kamaraj..😉
Devi Kamaraj..😉 - avatar
+ 3
Void does not return values,whereas int returns values
11th Dec 2019, 6:06 PM
kumaran
kumaran - avatar
+ 1
It's non-standard.
23rd Jul 2019, 10:19 PM
Vlad Serbu
Vlad Serbu - avatar