+ 1
Why return 0; is normally used in basic program.What is that can any one explain the use
3 Answers
+ 1
Really, nothing would happen, unless you were using a script that ran multiple C++ files, one after another. A "0" return just tells the OS that the program ended without any errors, and a non-zero return just means some sort of error occured, but it really doesn't change much.
0
As you probably know, every C++ program must have a "main()" function. For example in the code below:
int main() {
return 0;
}
Now, look at the "int" in front of the "main()." This is the return type of the "main()" method (if you haven't learned about methods/functions... then after you do, you will probably understand.
The return type is the type of value the function will return to it's call(s), as the name suggests. The "return 0;" is just to end the program properly, as without it, the "main()" function is improperly defined, and will raise an error, because it doesn't return the int it is supposed to return.
Hopefully this made sense, if not now, later. Happy coding! đ
0
I use return 1 instead of return 0 what will happpen