Preconditions:
Addresses of 2 integer variables are on the stack as the parameters.
Sample c call: swap( &num1, &num2);
You must implement the following C swap function:
/*
Swaps the two values pointed to by x_ptr and y_ptr.
*/
void swap (int *x_ptr, int *y_ptr)
{
if (x_ptr != y_ptr)
{
*x_ptr ^= *y_ptr; /* note that ^ means xor */
*y_ptr ^= *x_ptr;
*x_ptr ^= *y_ptr;
}
}
Postconditions:
The values of the two integer parameters have been exchanged.