New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Return type of main function?
Is it necessary to have return type of main function as int (and not void)? Why does the code show a compilation error? https://code.sololearn.com/czUK2qE6vJyq/?ref=app https://code.sololearn.com/czUK2qE6vJyq/?ref=app
2 Answers
+ 3
if the code returns a 0, it means the code compiled succesfully and if it returns a -1 it means the code had a error, and if the main is a void it cant give a return value.
correct me if im wrong
+ 1
In C++, returning an integer from the main function is necessary.