given the following array (for example):
int arr[6] = {1 , 2 , 3 , 4 , 5, 6};
If I send it to function with the following decleration:
int func(void* array, int n);
How can I send from func to the following function:
int f(void* element);
address for some element in the array?
I tried to do something like that: f(array + i); (in order to send &array[i]) , but I get the following error:
pointer of type 'void *' used in arithmetic
So , how can I do it?
funconly called withintarrays, or can thearrayargument tofuncbe of a different type?funcknow the type ofarror not? If not, then you are probably out of luck. You'd have to pass along the item size in that case.int*first.f((int*)array + i)arrayis not onlyintarray .int size_that will describe the size of any element in the array?