pointers-memory · intermediate · ~15 min
Pointer subtraction yields an element count, not a byte count.
Implement int ptr_distance(const int *a, const int *b) returning how many int elements b is past a (b - a).
int ptr_distance(const int *a, const int *b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.