+ 1
return type
what is the effect on program if we write return0; or return1; ?
2 Answers
+ 2
I found a decent reading on SO regarding program exit status, an answer from a member by the name BoBTFish covers both Unix/Linux and Windows perspective:
https://stackoverflow.com/questions/12512177/exit-status-of-a-program
Hth, cmiiw
+ 1
If You're talking about the return type of the main function, give a look at this: https://www.codeproject.com/Questions/693038/why-do-we-have-to-use-return
and
http://www.cplusplus.com/forum/beginner/147175/
Unfortunately, I don't know much about languages other than C#, so I'll try to explain the best as I can. When You create a non "void" method,
You need to RETURN Its type back to whatever method is calling It.
Differently than C++, C#'s main method is a void, so We don't need to return nothing at the program's end, but when It comes to C++, We NEED to return "0" (which means everything ran fine), because Cpp's main method is an "Int".
If something went wrong during the execution, the return type will be other than zero, and It uses to occur "automatically", You don't need to explicitly return "1" (or whatever) in your code.
[ANYONE please tell me if my answer is wrong, I'm learning too]