Next: Loop Statements, Previous: Blocks, Up: Statements [Contents][Index]
return
StatementThe return
statement makes the containing function return
immediately. It has two forms. This one specifies no value to
return:
return;
That form is meant for functions whose return type is void
(see The Void Type). You can also use it in a function that
returns nonvoid data, but that’s a bad idea, since it makes the
function return garbage.
The form that specifies a value looks like this:
return value;
which computes the expression value and makes the function return that. If necessary, the value undergoes type conversion to the function’s declared return value type, which works like assigning the value to a variable of that type.