I have a function which receives an address of a pointer to an array, I want the function to iterate that array, how exactly should I write the function’s code?
example of the function, and the function’s call:
int example(int** arr, int n){}
k = example(&arr, n);
Using *arr, gives me the address of the first object in the array, using **arr gives me the value of the first object in the array.
But how do I access the next objects of the array is what I’m struggling with, let’s say I want to iterate through the array in a for loop for example.
>Solution :
Just treat *arr as an array
int *array = *arr;
for(int i = 0; i < n; i++)
{
// do something with array[i];
}