basics · beginner · ~15 min
Why pointers exist: a function can mutate caller-owned values.
Implement void swap(int *a, int *b) that swaps the integers *a and *b. This is your first pass-by-pointer.
void swap(int *a, int *b) {
/* TODO */
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.