Why are the contents pointed to by a pointer not changed when memory is deallocated using free()?
问题 I am a newbie when it comes to dynamic memory allocation. When we free the memory using void free(void *ptr) the memory is deallocated but the contents of the pointer are not deleted. Why is that? Is there any difference in more recent C compilers? 回答1: Computers don't "delete" memory as such, they just stop using all references to that memory cell and forget that anything of value is stored there. For example: int* func (void) { int x = 5; return &x; } printf("%d", *func()); // undefined