This is some sample code, but it basically shows my Problem (i wrote this freestyle without compiling it so it might have some syntax error but it's just about the idea).
typedef struct Person {
char name[25];
}Person;
int main() {
Person *p = malloc(sizeof(Person));
strcpy(p->name,"Philip");
free(p);
printf("%s",p->name); /* prints Philip but why? */
return 0;
}
So i'm allocating space for p and after i gave it the name of "Philip" i free() it. So, in my understanding, p->name should be NULL. Am i using free incorrectly? Isn't it "bad" that the string 'name' still stays in my ram?