{ char*dp = NULL; /*
... */ { char c;
dp =&c; }/*
c falls out of scope */ /*
dp is now a dangling pointer */ }
#include void func() { char*dp = malloc(A_CONST); /*
... */
free(dp);/* dp now becomes a dangling
pointer */
dp = NULL;/* dp is no longer dangling */ /*
... */ }
int*func(void) { int num =1234; /*
... */ return# }
int f(int i) { char*dp;/*
dp is a wild pointer */ staticchar*scp;/*
scp is not a wild pointer:
*
static variables are initialized to 0
*
at start and retain their values from
*
the last call afterwards.
*
Using this feature may be considered bad
*
style if not commented */ }