+ 1
Why can't we use void main instead of int main and return nothing.
3 Respuestas
+ 1
you can also use void main instead of int main. it is completely depends upon you what's you want to use.
if you don't have any need to return anything from main function than you can use void main also.
but mostly you will see main function is written as a int main() and it's will return something 0 or 1.
so may be it's just a way for standard programming so everyone follows it. but personally i always use void main().
+ 1
C++ recognizes the int main() and runs the code inside when the program is run. If you make a void main() instead of an int main() it will not recognizes it as a main function and will not run it when the code starts!
You also ways need the main to be of type int!!!
0
You can use void main in case you don't need to return something from main , in case the code won't run type : system("pause") before you close main