Possible Duplicate:
What should main() return in C/C++?
why do we give int main in c++ and not void main?
I’ve started learning C++ and the following question came up to my mind: main() always return int? Cannot I declare void main() instead of int main()?
Thanks you!
Yes,
main()must returnint. The return value is passed back to the operating system, to indicate whether the program ran successfully: zero means success.However, you can leave the
returnstatement out ofmain(and onlymain) if you like; in that case, it will return zero.