pointers-memory · beginner · ~15 min

Set a value through a pointer

Write through a pointer with the dereference operator.

Challenge

Implement void set_via_ptr(int *p, int v) storing v into the int that p points to.

Starter code

void set_via_ptr(int *p, int v) {
    /* TODO */
}

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