function Description
void* realloc (void* ptr, size_t size);
GrammarPointer name = (data type *) realloc (to change the memory size of the pointer name, the new size). The new size can be large and small (but note that if the new size is smaller than the original memory size, it may result in data loss, use caution!) )header File#include <stdlib.h> some compilers require # include <malloc.h>, alloc.h header files can be used in TC2.0functionFirst determine whether the current pointer has enough contiguous space, if there is, expand the address pointed to by Mem_address, and return mem_address, if the space is not enough, first in accordance with the size specified by newsize to allocate space, the original data from beginning to end copied to the newly allocated memory area, Then release the original mem_address memory area (Note: The original pointer is automatically freed, do not need to use free), and return the new allocated memory area of the first address. That is, the address of the memory block is redistributed.return valueReturns a pointer to the allocated memory if the reallocation succeeds, otherwise null pointer is returned.NoteUse the free () function to release memory blocks when memory is no longer in use.
[C + +] Realloc Memory