Because of C’s pass by value semantics, passing data into functions using parameters requires pushing and popping that data onto and off the stack, byte by byte. Using return values to pass data out of a function back to the callee also requires copying the data onto the stack.
If you’re just passing or returning an
int, then this is no big deal, but if you’re passing big data structures then all that copying can soon mount up.
The solution is to pass pointers into the function instead:
Using a pointer means passing only a few bytes rather than the whole structure. For a large array for example, instead of saying “here’s the contents of the array”, pointers allow you to say, “here’s where you can find the array already in memory”.