Difference between realloc() and free?

1 votes
151 views
Jivika Rai asked 12-Dec-2017 in Technology by Jivika Rai

Difference between realloc() and free?

1 Answer

0 votes
Sangsaptak Pal answered 28-Jan-2020 by Sangsaptak Pal

Both realloc() and free() are functions of C programming language used for dynamic memory allocation. Both of the functions are defined in the stdlib.h library. 

realloc() : It is a function which is used to dynamically reallocate memory space to an already dynamically allocated memory space to a variable.

free() : It is used to deallocate or free the dynamically allocated memory space allocated to a variable and thus make it available to other variables or other memory functions of the operating system.

Difference between realloc() and free?

Image for free() function

Difference between realloc() and free?

Image for realloc() functions