I wrote a program in C having dangling pointer.
#include int *func(void) { int num; num = 100; return # } int func1(void
It's undefined behavior. It could work correctly on your computer right now, 20 minutes from now, might crash in an hour, etc. Once another object takes the same place on the stack as num, you will be doomed!
num