What is the main difference between void main and int main ? Pls answer my question thank u. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the main difference between void main and int main ? Pls answer my question thank u.

27th May 2017, 6:15 AM
YASH KATARE
YASH KATARE - avatar
3 Answers
0
There are not. In C++, the main function is a int, we use it to return if the program works or not (return 0: Ok, all is good, return any other: There is an error). But this is only a convention and this is why a void main function hasn't difference with an int main.
27th May 2017, 6:31 AM
Volts
Volts - avatar
+ 4
in the basically c++ start executing with main() than the int main always return something like we mostly use return 0 but we can take anything else too....where as void there nothing we need to return
28th May 2017, 3:38 AM
Bhavin Kanzariya
Bhavin Kanzariya - avatar
+ 2
Void main isnt accepted as valid in C++. Your compiler will quietly tell you to fuck off and it will secretly compile it with main returning a value
27th May 2017, 7:33 AM
aklex
aklex - avatar