Thursday, July 30, 2009

C++ exit code..?

Hi, can some1 explains to me what this return codes mean in C++? return 0, return 1, return -1 Thanks

C++ exit code..?
The value returned may have an intrinsic meaning depending on where it is placed.





If the value is in the "main" subroutine, returning zero is a good thing. It says that the program exited normally. Returning anything else generally signifies an error.





As far as any other routine, 0 is false and anything else is true. (Although, you should use explicit constants if you're looking for a Boolean answer.)





HTH
Reply:Returning values of a specific (int) function. The meaning (if is your function and no predefined function in some lib) is yours to choose...
Reply:it makes the function return a value...this is probably best shown by an example





int function


{


cout %26lt;%26lt; "I like tacos and rockstars";


return 17;


}





now the value of int function (yes, the FUNCTIONs value)


has a value of 17 when that function finishes all lines of code.
Reply:The return keyword allows you to specify what variable or value will be passed back to the calling function when the function it is in is terminated. It can be used to determine a runtime status for a function or to pass a pointer to a data object / structure so that multiple results can be retrieved.


No comments:

Post a Comment