+ 3
Why we use return zero in main why not 1???
when ever main ended ,we are returning a value most of cases it is 0 not 1 if main asking for return value if it is void then there is no question of zero or one
3 odpowiedzi
+ 17
"The return value for main should indicate how the program exited. Normal exit is generally represented by a 0 return value from main. Abnormal termination is usually signalled by a non-zero return but there is no standard for how non-zero codes are interpreted.
...
It's also worth noting that in C++, int main() can be left without a return value at which point it defaults to returning 0."
Source: http://stackoverflow.com/a/204483
+ 1
Because the exit code is answering the question "were there any problems?" Moreover, it's actually more than just a boolean: the number returned is a code that can specify what sort of error it was. IMHO, that's why Thompson and Ritchie decided to use 0 as "no problem" for "int exit()" in Unix. Then "return 0" is success in C/C++.
+ 1
Because the exit code is answering the question "were there any problems?" Moreover, it's actually more than just a boolean: the number returned is a code that can specify what sort of error it was. IMHO, that's why Thompson and Ritchie decided to use 0 as "no problem" for "int exit()" in Unix. Then "return 0" is success in C/C++.