append dynamic memory or something
hi...
I was just wondering if there are ways to append or withdraw dynamically allocated memory.
Say I've got an array:
int *array;
array = new int[20000];
and assign values to the array. If I now want the array to contain
21000 elements with the first 20000 elements being the same, do I have to allocate a buffer to contain the 20000 elements, then delete the original buffer, allocate a new:
array = new int[21000];
and assign the first 20000 elements, delete the buffer and assign values to the 1000 last elements, or(I guess you see where this is going) can I just append 1000 elemnts to the original array.
The buffer technique, for large arrays, can cause considerable memory problems! although I guess an append function would also run across some problems.
Anyway, are there such functions?
thanks
/aronn