Google News
logo
Embedded C - Interview Questions
What is the purpose of realloc( )?
The realloc function is used to resize the allocated block of memory. It takes two arguments first one is a pointer to previously allocated memory and the second one is the newly requested size.
 
The calloc function first deallocates the old object and allocates again with the newly specified size. If the new size is lesser to the old size, the contents of the newly allocated memory will be the same as prior but if any bytes in the newly created object goes beyond the old size, the values of the exceeded size will be indeterminate.
 
Syntax :
void *realloc(void *ptr, size_t size);
Advertisement