I have the code below which contains a dynamic array of strings. I'm having problems deallocating each individual string that is generated. I assumed I could just include a new for loop which deallocated them but that didn't work. How should I be doing this?
//A dynamically allocated array of char pointers
int numOfStrings = 10, numOfChars = 32;
char** data = new char*[numOfStrings];
//Generate each each individual string
for(int i = 0; i <numOfStrings; i++)
data[i] = new char[numOfChars];
//moves the elements 1-5 in the array to the right by one
int index = 1, boundary = 5, sizeToMove = (boundary - index) * sizeof(numOfChars);
memmove(&data[index + 1],&data[index],sizeToMove);
for(int i=0;i < numOfStrings; i++)
delete [] data[i]; //this line is causing an exception on its first call (I've also tried delete data[i].
delete[] data;