In C, a function always returns its value to the calling function and never to itself (if return type is not void). Like,
i
This is completely OS-specific, but usually the OS invokes a program by
main
and stores the return value in the OS internals.The function I'm referring to in (3) is often a good old fashioned C function that just jumps into main
so it can capture the return value from main
as if it were an ordinary C function (which it in fact is). Afterwards, it stores that value somewhere in OS-land so that processes that need to read the return value can do so.
Hope this helps!