The simple solution is to provide a second parameter for the array size:
Code:
void iter_ints(int arr[], size_t arrSize)
{
printf("arrSize %zu\n", arrSize);
// ...
}
I have chosen size_t as the type of arrSize because that is the type of the result of sizeof. Likewise, the format specifier for printf was changed to %zu as that is the format specifier for size_t. If your compiler complains about this, then change %zu to %lu and cast arrSize to unsigned long.
You might call this function like this:
Code:
int numbers[] = {2, 3, 5, 7, 11};
iter_ints(numbers, sizeof(numbers) / sizeof(numbers[0]));
In this context, the sizeof division method works fine because numbers really is an array, not a pointer. In iter_ints, the sizeof division method does not give you the size of the array because arr is actually a pointer, hence we pass the array size as an argument.