Resizing dynamically allocated memory

I'm dynamically allocating memory for a 2-d array (char ** genresList) thus:

1
2
3
4
genresList = new char * [numStrings];        
  for ( int row = 0; row < numStrings; ++row ) {
        genresList[row] = new char[MAXLENGTH]; 
  }


where numStrings is read in from an external file.

During processing I might wish to add entries to the array e.g numStrings is now numStrings + 1. Now, my original dynamically allocated array is of fixed (numStrings) size. To add to the array would I need to delete the existing array and then create a new array using numStrings + 1?

I know there is a C realloc() function but I wish this to be a C++ solution.
You can't resize arrays allocated with new. You have to either copy the contents to a bigger one or use std::vector.
Helios: Thanks. I thought as much but just wanted to check.
Topic archived. No new replies allowed.