in both c++ and c, how to increase the size of an array dynamically
Posted on 2003-11-02
in c using malloc and calloc, we can assign space in heap to a data structure (e.g., array)
If during run time i want to increase the size of the array how can i do it?
realloc in c allocs new space equal to current space + additional required spce at a differenct location.
But if it cannot find
current space + additional required spce
amount of free memory which is together, it refuses to allocate new memory. though there is enough space for
additional required space
so how to get over this.
In c++ i don't know any function like realloc. I think it is possible using new itself, but i don't know how to use it. Please help clarify this to me .