+ 6
Why void main shouldn't be used instead of int main?
Function
7 Respuestas
+ 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
+ 3
Fine. But the return type of all the coding shouldn't be of int type na
+ 3
The same thing I mentioned in my question. Thanks ushasri mavuri.
+ 3
Void does not return values,whereas int returns values
+ 1
It's non-standard.