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.
Parameters
- ptr
- 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.
Return Value
(none)Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
This program has no output. Just demonstrates some ways to allocate and free dynamic memory using the cstdlib functions.
See also
| malloc | Allocate memory block (function) |
| calloc | Allocate space for array in memory (function) |
| realloc | Reallocate memory block (function) |
