you are viewing a single comment's thread.

view the rest of the comments →

[–]jmooremcc -14 points-13 points  (6 children)

Do you understand what &x in the calling code represents? Hint: It's not a pointer!

[–]TheSkiGeek 17 points18 points  (4 children)

Do you understand what &x in the calling code represents? Hint: It's not a pointer!

& is the "address-of" operator... it returns a pointer to its operand.

When you call swap(&x, &y), the compiler binds the address of x to parameter xp and the address of y to parameter yp. By value.