English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

2006-08-29 03:54:46 · 4 answers · asked by digitex 1 in Computers & Internet Programming & Design

4 answers

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

2006-08-31 06:11:00 · answer #1 · answered by Clif B 1 · 1 0

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.

2006-08-29 11:13:14 · answer #2 · answered by griz803 5 · 0 0

it makes the function return a value...this is probably best shown by an example

int function
{
cout << "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.

2006-08-29 18:47:00 · answer #3 · answered by D 4 · 0 0

Returning values of a specific (int) function. The meaning (if is your function and no predefined function in some lib) is yours to choose...

2006-08-29 11:11:12 · answer #4 · answered by None A 3 · 0 0

fedest.com, questions and answers