Practice ยท 2 of 4
Distance Between Pointers
Implement range queries with pointer subtraction:
``c
/* returns how many elements lie in [lo, hi) of array a (n elements),
where lo and hi are pointers INTO a (or hi == a + n). Invalid inputs
(NULL, hi < lo, pointers outside the array's [a, a+n] range) return 0. */
size_t span(const int *a, size_t n, const int *lo, const int *hi);
``
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Address Walking Gym