I\'m working on a function to swap pointers and I can\'t figure out why this isn\'t working. When I print out r and s in the swap function the values are swapped, which lea
The line r=s is setting a copy of the pointer r to the copy of the pointer s.
r=s
r
s
Instead (if you do not want to use the std:swap) you need to do this
void swap(int *r, int *s) { int tmp = *r; *r = *s; *s = tmp; }