Published Aug 18, 2022
Contribute to Docs
free() function is used to dynamically de-allocate the memory at runtime. Memory allocated by the
calloc() functions must be manually de-allocated when not in use. Freeing it helps to reduce memory wastage.
memoryblock must exist beforehand in order to be de-allocated by the
The following example showcases the
int *ptr;// Memory allocated using malloc() functionptr = (int*) malloc(5 * sizeof(int));// Memory de-allocated using free() functionfree(ptr);
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.