Why we use void for main function... What the use of void in main?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use void for main function... What the use of void in main??

12th Apr 2017, 9:02 AM
Mannat Khatri
Mannat Khatri - avatar
4 Answers
12th Apr 2017, 2:42 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
void is a datatype. the main function does not return a value if you use "void" . For other datatypes like int,float you have to return something at the end.. This not just or c++.
12th Apr 2017, 9:12 AM
Sandeep Balachandran
Sandeep Balachandran - avatar
+ 3
as far as I know, int is used for main function to return the status of the program(i.e. return 0; means program ran to the end successfully) I don't think void main in for c++
12th Apr 2017, 9:23 AM
Mohammad Ganji
Mohammad Ganji - avatar
+ 2
http://www.stroustrup.com/bs_faq2.html#void-main Don't use void main as it is not C++.
12th Apr 2017, 9:17 AM
Dennis
Dennis - avatar