function pass control

Can anyone help me with this?....
How does a function pass control back to the calling function?
return data_type_of_function or in the case of void just let the function run its course
For functions that are declared to return nothing (void), either the function can complete or there can be "return;" somewhere.

For functions that are declared to return a value, the function must at some point "return some_value;"

For all cases, functions may throw exceptions which could be caught in a higher calling function.
the value though must be the data type declared with the prototype
@Aramil: Firstly, you don't even need to have a prototype. The actual definition determines the type that must be returned, the prototype and definition just have to match.

Second, it doesn't have to return a variable which matches the type of the return type of the function. It can, or it can return a variable that is implicitly convertible to the return type. Details matter ;)
thank i didnt know that. well, i mean i knew about the prototypes but are you saying something like it returns a bool and its meant to return false so it returns 1 (I believe 1 is false but i could be wrong)
false is defined as 0, and true is defined as "not false" (eg 1 or any other number besides 0)
ok ty I couldnt remember which
Topic archived. No new replies allowed.