+ 1

Why does the C++ main function return an integer?

return value in C++

6th Dec 2017, 1:56 PM
Bits!
4 Answers
+ 2
Thanks..
6th Dec 2017, 4:23 PM
Bits!
+ 1
It is a pre-defind status tht is reported from the kernel source, right? If any hacker hack the protected resource kernel and change it to 1-success as well as 0-failed. Then we can say it isn't a bug of Code:Blocks..! Just my couriousness..?
6th Dec 2017, 2:22 PM
Bits!
+ 1
It's something that's reported to whatever executed the program, which most often is the OS, but not always the case. It's just an additional layer of being able to handle errors, more specifically when the program is ending.
6th Dec 2017, 3:00 PM
AgentSmith
0
It's returning an exit status to the OS (or whatever executed the program) to help with reporting error. 0 - success, non-zero - failed.
6th Dec 2017, 2:58 PM
AgentSmith