Why the dangling pointer in the following program shows the same memory address even after freeing the memory?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 1;
int *ptr_a = (int*)malloc((sizeof(int)));
ptr_a = &a;
printf("The address of 'a' is %p\n", ptr_a);
free(ptr_a); // A dangling pointer
printf("The address of 'a' is %p", ptr_a);
return 0;
}
I tried everything but still getting the same problem.