What is meant by this act? (int (*) [10])
4 answers
It is a pointer to an integer array of size 10, not a pointer to a pointer to int.
For example, when you pass the type
char arr[20][10]
to the function it decays to inject char (*) [10]
Since the compiler needs to know no columns to efficiently convert a 2d array to linear in memory, this is not the same as int **.
+6
source to share
Here's a training example that matches your observation (compiled with no warnings):
int array[10]; /* an array of 10 ints */
int (*ptr)[10] = &array; /* a pointer to an array of 10 ints */
/* a function which receives a pointer to an array of 10 ints as param */
int myfunc (int (*param)[10])
{
return 10;
}
int main(void)
{
/* a pointer to a function that accepts a pointer to an array of 10 ints as parameter and returns an int */
int (*func)(int (*)[10]);
func = myfunc; /* no cast needed. The objects are of the same type */
/* func = (int (*)(int (*)[10])) myfunc; */ /* with cast */
(*func)(ptr); /* function pointer called with ptr parameter */
return 0;
}
+2
source to share