i write this code to reverse an array and save the result in the same one
if n=3 i expect
a[0]=0 a[1]=1 a[2]=2 (before rev is OK but after calling rev)
a[0]=2 a[1]=1 a[2]=0 (expected result )
but i get
n=3
console out
-----------------------------------
n
3
a[0]=0
a[1]=1
a[2]=2
a[0]=2293572
a[1]=4469856
a[2]=4199425
Press any key to continue . . .
--------------------------------------------
If the size of the array is n then valid indices are from 0 to n-1, so a[n] is out of bounds. What you probably meant to do is to pass a pointer to the first element in the array rev(&a[0],n);, or rev(a,n); will also work.