pointers-memory · beginner · ~15 min
Read a value via dereference.
Read the value of a variable through a pointer to it.
Implement int deref(const int *p) that returns the int value p points to. No main — the grader calls it.
p — a pointer to a valid int (never NULL in the tests).
Returns the int stored at *p.
int x = 7; deref(&x) -> 7
int y = -9; deref(&y) -> -9
p — a pointer to an int.
The int value at *p.
int deref(const int *p) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.