Lesson 19 of 23
Call by Reference: Swap
9 min 35 XP
Pass a variable's address and the function can change the variable itself. That's exactly how scanf(&x) works, and it is also how a function returns more than one value.
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Passing an array to a function passes the address of its first element, so changes made in the function are visible in main too.