When I'm dereferencing and printing the output of a given array pointer, I'm getting my array in reverse. Here's the code
using namespace std;
int main()
{
int arr[5] = {1,2,3,4};
int* ptr = arr;
cout<<ptr<<endl;
cout<<*ptr++<<endl;
cout<<*ptr<<" "<<*ptr++<<" "<<*ptr++<<" "<<*ptr++;
return 0;
}
Output
0x61fee8
1
0 4 3 2
But since I filled the array in increasing order and incremented the pointer I was expecting the output to be as
1 2 3 4
and why there is a zero in 2nd line?