pointers-memory · intermediate · ~15 min
Follow two levels of indirection.
Follow two levels of indirection: a pointer to a pointer to an int, down to the int itself.
Implement int deref2(int **pp) that returns the int reached by dereferencing pp twice (**pp). No main — the grader calls it.
pp — a pointer to an int*, which in turn points to a valid int.
Returns the int value at **pp.
int x = 5; int *p = &x;
deref2(&p) -> 5
x = 99;
deref2(&p) -> 99
pp — a pointer to an int* that points to a valid int.
The int value at **pp.
int deref2(int **pp) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.