+ 1

Why r u not accepting void main() instead of int main() ?

15th Dec 2016, 6:29 PM
Hiranmayi
Hiranmayi - avatar
2 odpowiedzi
+ 2
it's a standard! return value of main() is verified to decide whether the program ran successfully without errors and in handled exceptions. return 0 is used to imply successful execution. any other return value simply denotes failure Some compiler softwares on Windows allow void main() but then they are NOT standard!!!
15th Dec 2016, 7:59 PM
Caffeinated Gamer YT
Caffeinated Gamer YT - avatar
+ 1
Hey Hira , I would like to correct you if you don't mind . the correct way to define main is int main (int argc, char ** argv) and void main(int argc, char **argv ) as per the C++ spec . coming to your question . it's common confusion arise to C++ beginner is Should I use Void or int ?? main() must return int . some compiler accept Void main ( int argc, char **argv), BUT THAT IS NON STANDARD AND SHOULDN'T BE USED. instead use int main (int argc, char **argv) { return 0; } if you don't know what else return just say Return 0; return 0 ; meaning successful execution of program Hope you understood ..
15th Dec 2016, 7:03 PM
Mock
Mock - avatar