I allocated memory for pointer using malloc function. I had deallocate memory using free. But whenever I'm trying to print the content of pointer it prints the content.
Then what is the use of free()?
I allocated memory for pointer using malloc function. I had deallocate memory using free. But whenever I'm trying to print the content of pointer it prints the content.
Then what is the use of free()?
free()
just marks the memory as available (as in, it can be used for further allocations). It does not removes the content of the memory.
That said, you should not access the content of a free
d memory, as it is Undefined Behavior.