This is a simple program I wrote to induce segfault
 #include<iostream>
using namespace std;
char* func(){
    char ch='a';
    char *ptr=&ch;
    return ptr;
}
int main()
{
    char *ptr=func();
    cout<<*ptr;
}
As variable ch must've been freed after func() scope ends, I thought that this program would give segmentation fault. But it shows output as 'a'. What am i missing ?
