Use push_back() to add a string and erase() to delete something and the std::vector will automatically manage size for you.
Vart means that you create an array on the heap:
Code:
record* p = new record[n];
The only problem is that you must remember the size yourself and delete, reallocate and copy if it gets too big:
Code:
int size = 100;
int curelement = 0;
record* p = new record[size];
//...
if (curelement + 1 > size) // Not enough room, reallocate
{
record* p2 = new record[size * 2];
memcpy(p, p2, size);
size *= 2;
delete [] p;
p = p2;
}
Of course, you should really use std::copy, but that's another matter.