+ 2
Why can't I use void main instead of int main.
4 odpowiedzi
+ 3
most compilers support int main. Also int main() can help to return the error code if your program fails due to some error.
(Pre exception handling days, now you may use exception handling to handle issues,
perhaps that's the reason in java we go as public static void main () ) So it mainly depends on the compiler you use.
+ 3
If you are using void main instead of int, make sure you dont return anything at the end of main function (most cases its return 0;)
+ 1
void main will not return any value while using int main will return a value to our operating system which indicates that our code is compiled and executed successfully
0
with void main you have to use getch()