+ 1

Can i use void main() in place of int main()?

everytime i use int main() i have to use return 0... but in case of void main() i dont hav to do that

11th Oct 2016, 5:19 PM
Sidharth Sreenivas
Sidharth Sreenivas - avatar
5 ответов
+ 3
it depends on what compiler you are using if you are using linux based compiler you must use int main or if you are using code blocks or any such ide you should use int but in turbo c/c++ void will also work.
11th Oct 2016, 6:21 PM
Prabhakar Jha
Prabhakar Jha - avatar
+ 1
Yes why Not you can use a int main() in place of a void main(). In void main() you cannot return value but in int main() you can return values which are integers. There is no problem is you use int main() instead of void main().
28th May 2018, 3:53 PM
Param Kansagra
Param Kansagra - avatar
0
why?
11th Oct 2016, 5:42 PM
Sidharth Sreenivas
Sidharth Sreenivas - avatar
0
wat error?
11th Oct 2016, 5:43 PM
Sidharth Sreenivas
Sidharth Sreenivas - avatar
0
I just want to point out that even though main must be int, you can leave out the "return 0;". You usually can't do that but for the main function they made an exception.
11th Oct 2016, 10:10 PM
Schindlabua
Schindlabua - avatar