[prev] 54 [next]

Functions (cont)

When a function is called:

  1. memory is allocated for its parameters and local variables
  2. the parameter expressions in the calling function are evaluated
  3. C uses "call-by-value" parameter passing …
    • the function works only on its own local copies of the parameters, not the ones in the calling function
  4. local variables need to be assigned before they are used   (otherwise they will have "garbage" values)
  5. function code is executed, until the first return statement is reached