What is the difference between realloc() and free()? - C++

What is the difference between realloc() and free()?

- An existing block of memory which was allocated by malloc() subroutine, will be freed by free() subroutine. In case , an invalid pointer parameter is passed, unexpected results will occur. If the parameter is a null pointer, then no action will occur.
- Where as the realloc() subroutine allows the developer to change the block size of the memory which was pointed to by the pointer parameter, to a specified bytes size through size parameter and a new pointer to the block is returned. The pointer parameter specified must have been created by using malloc(),calloc() or realloc() sub routines and should not deallocated with realloc() or free() subroutines. If the pointer parameter is a null pointer, then no action will occur.
What is function overloading and operator overloading? - C++
What is function overloading and operator overloading? - C++ provides ability to overload most operators so that they perform special operations relative to classes.....
What is overloading unary operator? - C++
What is overloading unary operator? - Unary operators are those which operate on a single variable....
Difference between overloaded functions and overridden functions
Difference between overloaded functions and overridden functions - Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding....
Post your comment