I am going through a cpp course and the instructor used the following notation to get a subarray of the current array
void f(int arr[], int len) {
if (len == 0)
return;
f(arr + 1, len - 1); // arr + 1 takes a subarray
...
}
I wanted to understand how the arr+1
notation works with regards to memory. Arrays are passed by reference, but when you arr + 1 is a copy of the array from the provided offset created, or does it simply advance some pointer and no extra memory is used?