Type int can hold -32768 to +32767.
1000000 is going to overflow on the convert and the math you do with length won't work as int.
I'll wait to see what others say about that parameter syntax. When you did call the function it took a pointer so perhaps it's not passing a copy of the array on the stack -but- if so then there should be scope problems as the array is local to loop(). Why not use a global array and pointer?