pointers-memory · intermediate · ~15 min

Swap two pointers

Mutate pointers through pointers-to-pointers.

Challenge

Implement void swap_ptrs(int **a, int **b) swapping the two pointers (not the values they point to).

Starter code

void swap_ptrs(int **a, int **b) {
    /* TODO */
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.