void main OR int main | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

void main OR int main

What is the difference between these two?

31st Jul 2016, 3:13 PM
Nikhil Yadav
Nikhil Yadav - avatar
2 Answers
+ 3
This question is asked more than twice a day on this forum and has been post lot of time this week. By the way, on the website of the author of c++ it's said in the FAQ that void main is not c++. So the best is to avoid it, even if some compilers allow that, it is not standard... A program should return 0 when everything gas been done with success and an other int value to refer an error code when something got wrong. source : http://www.stroustrup.com/bs_faq2.html#void-main
31st Jul 2016, 4:39 PM
Dorian
+ 2
here void and int are return type... they return value as null and in integer form respectively. but in void case there is no need to return type.
31st Jul 2016, 3:22 PM
Mayankesh Shyam Chitravanshi