You have two problems:
Array indexes are zero-based. That is, an array of N elements have indexes from 0
to N - 1
(inclusive)
The declaration int *v[1]
declares v
as an array of one pointer to int
, not as a pointer to an array of one int
. That would be int (*v)[1]
. Which is also the type of &v
from the main
function.
The solution to the second problem (using the correct type) then leads to a third problem, as it means that *v[0]
is incorrect due to operator precedence. You need to use parentheses here too, as in (*v)[0]
.
However the second (and the following third) problem is moot, since you don't need to pass arrays "by reference".
Arrays naturally decays to pointers to their first element. When using plain v
when a pointer to int
is expected, the compiler will automatically translate it as &v[0]
.
That means you could declare the function to simply take an int *
as argument, and simply pass plain v
as the argument.