Notice that this function leaves the value of ptr unchanged, hence it still points to the same (now invalid) location, and not to the null pointer.
- Pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated.
If a null pointer is passed as argument, no action occurs.
This program has no output. Just demonstrates some ways to allocate and free dynamic memory using the cstdlib functions.
|malloc||Allocate memory block (function)|
|calloc||Allocate space for array in memory (function)|
|realloc||Reallocate memory block (function)|