Hi All I have written a code as shown below
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int *fun();
int *p;
p = fun();
cout << "address contained in p " << p << endl;
cout << "value contained in p " << *p << endl;
cin.get();
}
int *fun()
{
int a = 20;
return (&a);
}
In the output i get
address contained in p 00f3fc48
value contained in p 26238874
why is output different from what i expected (*p=20 as i am returning address of a from function pointer)??
I am writing this code in visual studio.
Does compiler matters in this case?