realloc()

As the name suggests, this function is used to reallocate or resize the allocated memory. The reallocation of memory will not result in the loss of the existing data. Here is its syntax:

pointer= realloc(void *pointer, size_t new_blocksize);

Here, pointer is a pointer to the existing allocated memory block. new_blocksize represents the new size of the block in bytes and can be smaller or larger than the existing allocated block size.