I'm playing with c++ in VisualStudio2010
Please explain why IT happens:
int a, b;
int *p, *q;
cout << a << " " << b;
prints out "0 0". Well it's understandable, uninitialized integer should be 0; but
int a, b;
int *p, *q;
p = &a;
cout << a << " " << b;
output is "1792816880 0"
So if I assign pointer to uninitialized variable it change value from default. Why?
Edit clarification: the question was not about value of uninitialized variable
int a; int *p;
cout << a; // would be 0, because it's loacal variable
p = &a;
cout << a; //not 0;
How getting pointer of a could change it value? when we init variable, we allocate space, some bits, they could be anything, but "p = &a" does it actually change bits in this space?