A call to printf
printf("element %zu is %g, \tits square is %g\n", i, A[i], A[i]*A[i]); requests output using four arguments. The first is a format string; the remaining values supply the numbers placed at its format specifiers. section 1.1
A function call suspends the current function and hands control to the called function. When that function returns, execution continues after the call. C passes argument values: passing i does not let printf change i itself. To give a function access to an object, C can pass its address through a pointer. section 2.4.2 section 19.4
TAKEAWAY: A call has consequences beyond its printed result.
- Each call creates a new instance of its local objects. Recursive calls therefore have separate locals, although pointers can still give them access to the same data. section 19.4
- The call operator (...) also applies to function pointers. Even a call written f(3) involves conversion of the function name to a function pointer in C's abstract machine. section 11.4
- Do not infer left-to-right execution from an argument list. Calls used as separate arguments may run in either order, leaving defined behavior with different possible results when they have side effects. section 19.2
double f(double a); // Equivalent calls to f, steps in the abstract state machine f(3); // Decay → call (&f)(3); // Address of → call (*f)(3); // Decay → dereference → decay → call (*&f)(3); // Address of → dereference → decay → call (&*f)(3); // Decay → dereference → address of → call
Equivalent spellings of a call to f make the function-pointer conversion visible. section 11.4
Two possible results
If add(&a, &b) and add(&b, &a) are arguments to one printf call, one complete add call can precede the other or vice versa. Starting with a = 3 and b = 5, the shown program can print either “a = 8, b = 13” or “a = 11, b = 8”. Both outcomes are defined. section 19.2






