#include <iostream>
int main()
{
int a;
int *p = &a;
std::cout << *p << "\n";
}
In this program, when I leave a
uninitialized and try getting the output
of the pointer, it gives me -2
. But when I initialize a
with a value, printing *p
gives me that value. Why does it give -2
when I leave a
uninitialized?