why is void main not suggested to be used in a program ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why is void main not suggested to be used in a program ?

I would like to know why programmers suggest not to use void main

3rd Feb 2017, 1:42 PM
Nehal Choudhury
Nehal Choudhury - avatar
3 Answers
+ 8
Default thing in C++ is that "main" method is with return type int. You can write "void" but that is mainly used in earlier C
3rd Feb 2017, 2:55 PM
Filip
Filip - avatar
+ 6
Using int main() became the standard because using void main() may break existing code that expect a return.
3rd Feb 2017, 3:22 PM
Jafca
Jafca - avatar
+ 1
Actually the whole program runs IN the Main function. if you name another one of your funcions "main" you'll get in trouble as your compiler finds 2 functions named tje same and doesn't know how to handle them resulting in a compiler error.
3rd Feb 2017, 2:50 PM
seamiki
seamiki - avatar