The foo
function below finds the first occurrence of the given number and returns it's index. If the number wasn't found it returns the size of the array(n):
int foo(int arr[10], int num, int n)
{
; int *p
for (p=arr;(*p!=num) && (p<arr+n);++p);
;return p-arr
}
My question is: is the parameter int arr[10]
the same as writing int * arr
or int arr[]
for that matter? because when i pass an int array of size 100 i can iterate through it and i'm not capped to only 10 elements.