return return Statement
return [expression];
The return statement is used to terminate a function and return
control to the statement following the call. The return statement
may also be used to return a value.
Notes: If no value is returned, the return value is undefined.
Although it is a bad programming practice, it is possible
to return from multiple places in a function, returning a
value from some points, but not from others. This is
sure to bite you at some later time, and should be
avoided.
The return expression is often written as return(value).
The parentheses aren't necessary--but they don't hurt
anything.
A function may not return an array or another function.
It may, however, return a pointer to an array or
function. Most C compilers, including MS-C and Turbo C,
allow you to return structures and unions.
If the type of a function is other than `int', be sure to
declare the return type before you call the function.
Otherwise the return value will be treated as type `int'.
-------------------------------- Example ---------------------------------
if (condition)
return; /* Return value undefined */
if (condition)
return i; /* Value of i is returned */
if (condition)
return(i); /* As above; value of i is returned */
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster