+ 10

[DUPLICATE] Why int main() {} instead of void main() {}?

Why does the main function have to return a value?

10th May 2017, 1:40 AM
The Unknown
The Unknown - avatar
2 Answers
+ 10
Yes, its int main() because it returns 0. #include <iostream> using namespace std; int main() { return 0; //Here }
10th May 2017, 1:46 AM
Complex
Complex - avatar
+ 9
Yeah, main() has to return a zero to the operating system so that your operating system knows it finished successfully as per the C++ specification.
10th May 2017, 1:55 AM
Drayse Schneider
Drayse Schneider - avatar