swapping can be done in various ways in various programming languages:
Perl:
($a, $b) = ($b, $a);
C - macro version (doesn't work with structs, or floats. pointers should be cast to int):
#define SWAP(x,y) x^=y;y^=x;x^=y;
vi: press "x" followed by "p", to swap to letters.