There is a huge mess there, you need to get used to pointers!
Ok so your function gets
p which are
int *. What you give them is
p are also
int *. So you pass to your function type
*(g+i+3) so lets see what
g is the address of the address of the first element of your array.
i+3 spots next to the address of the address blah blah blah… so
*g[i+3] is the content of that!
It’s something you probably have no idea about!
Try to pass
p instead of
&p and remove all the
* from your function.