realloc Function
The
realloc ( ) function gives you a
means to change the size of a piece of memory space allocated by malloc ( ), calloc ( ) or by itself.
While adjusting the size of the allocated block to new one, it may copy
contents to the new location if necessary. Its declaration is of the form,
void *realloc ( void *block, size_t size );
Here
block points to start of memory
block obtained previously and size refers
to the new size for the allocated block. It returns a void pointer to newly
allocated block of memory. It returns a NULL pointer if it fails to reallocate
piece of memory space.
realloc ( ) is equivalent to malloc ( ) if the first argument
passed to realloc ( ) is NULL
float *ptr;
ptr = (float *) realloc (
NULL, 10*sizeof (float));
Post a Comment