+ 2

Why can't I use void main instead of int main.

16th Aug 2016, 4:48 AM
Amitesh
Amitesh - avatar
4 Respostas
+ 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.
16th Aug 2016, 6:15 AM
alcatraz
alcatraz - avatar
+ 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;)
16th Aug 2016, 9:17 AM
Bekir Uzun
Bekir Uzun - avatar
+ 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
16th Aug 2016, 8:23 PM
Shubham Mittal
Shubham Mittal - avatar
0
with void main you have to use getch()
19th Sep 2016, 4:51 PM
rishika