Practice ยท 4 of 4
Swap Through Qualifiers
Implement two swap variants that demonstrate the const contracts:
``c
void swap(int *x, int *y); /* ordinary swap */
int swap_if_sorted(const int **px, const int **py); /* if **px > **py, swap the
POINTERS so *px ends up pointing at the smaller value; returns 1 if swapped */
`
swap_if_sorted` takes pointers-to-pointers-to-const: it may move which pointer
points where, but never write through to the ints.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Address Walking Gym