This is my code:
using namespace std;
// if memory is alloted statically then you can't access memory address after the function has returned and its stack is gone.
int* function(int x)
{
int *x_ptr = &x;
return x_ptr;
}
int main()
{
int x=10;
int *x_ptr = function(x);
cout<<*x_ptr<<endl;
}