The return statement forces a return from a function and can be used to transfer a value back to the calling routine. It has these two forms:

 return; return value;

In C99 and C++, the form of return that does not specify a value must be used only in void functions.

The following function returns the product of its two integer arguments:

int mul(int a, int b) {   return a*b; }

Keep in mind that as soon as a return is encountered, the function will return, skipping any other code that may be in the function.

Also, a function can contain more than one return statement.

C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539 © 2008-2017.
If you may any questions please contact us: