Why isn't the following example correct? Why doesn't it demonstrate a dangling pointer? My teacher said it doesn't show the dangling pointer. Thanks in advance!
int X = 32;
int *p = &X;
free(p);
*p = 32; //<------Shouldn't this line cause dangling pointer ???
Same thing here. Why doesn't the following example demonstrate a memory leak?
void function(int x){
int *p = &x;
*p = 32;
//shouln't this code show a warning as p was not freed?
}