We are using : Turbo C3 Compiler on Windows XP.
We have a question for following code snippet:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char *ptr;
ptr=(char*)malloc(10*sizeof(char));
strcpy(ptr,"data structure");
printf("\n *ptr=%s \n add=%u",ptr,ptr);
free(ptr);
printf("\n *ptr=%s \n add=%u",ptr,ptr);
getch();
}
In the above program, even after freeing ptr, the value of ptr and address of ptr is showing correctly.
Please tell the solution & reason behind this problem. Thanks KB