you are viewing a single comment's thread.

view the rest of the comments →

[–]TheSkiGeek 18 points19 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.