i have one scenario like below
#include <stdio.h>
int main(void) {
int *p1=NULL;
int a;
p1=&a;
printf("%p\n",p1);
p1=NULL;
printf("%p\n",p1);
return 0;
}
In this case i have no problem at all.but if i use like this as below:
#include <stdio.h>
int main(void) {
int *p1=NULL;
int a;
p1=&a;
printf("%p\n",p1);
free(p1);
printf("%p\n",p1);
return 0;
}
In this case, i got run time error as below:
Runtime error time: 0 memory: 2052 signal:11
I want to know why it is happens like that. As far i know, freeing the
pointer will do same thing as assigning it NULL value(mean when we do
free(p) it also delete the pointer link to memory instead of deleting the
allocated memory space). I would rather if you could possibly suggest me
anything on that.
Thanks in Advance.