I am trying to learn pointers with arrays.
I want to do this with the function below:
int* ArrayManipulator(int* arrayPoiner, const int size)
to reverse the array list:
#include <iostream>
using namespace std;
int* ArrayManipulator(int* arrayPoiner, const int size)
{
int i=0;
int tt[size];
for (i=0;i<=size;i++)
{
cout<<arrayPoiner[size-i]<<endl;
cout<<&arrayPoiner[size-i]<<endl;
tt[i]=arrayPoiner[size-i];
}
return tt;
}
int main()
{
int t[]={1,2};
int *ReversedArray;
ReversedArray = ArrayManipulator(t,1);
int i=0;
for (i=0;i<2;i++)
{
cout<< ReversedArray[i]<<endl;
}
return 0;
}
I am receiving error at cout<< ReversedArray[i];
cout<< &ReversedArray[i]; is printing the address of the value but I am unable to print the value - codeblocks error out there
I want the final two lines to be 2 and 1, where am I going wrong on code.

ArrayManipulatorreturns a pointer to an array that was allocated on the stack; this invokes undefined behaviour.