How can you increase the size of a dynamically allocated array?

Showing Answers 1 - 3 of 3 Answers

ptr=realloc(ptr,newsize);

This function allocates a new memory space of size  newsize to the pointer variable ptr  and returns a pointer to the first byte of the new memory block.
The new size may be smaller or larger than the size.

If the function is unsuccessfull in allocating additional space,it returnas a NULL pointer and the original block is freed.(lost).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions