Hello I am having a problem with this function. Everything works fine until it reaches the delete []dynamicArray
line. Can someone please tell me why it would crash at this part?
string* addEntry(string *dynamicArray, int &size, string newEntry)
{
string* hold;
hold = new string[size + 1];
for (int i = 0; i < size; i++)
{
*hold = *dynamicArray; //copy the names over into new array
hold++;
dynamicArray++;
}
*hold = newEntry; //add the new name
size++;
delete []dynamicArray; //delete the old array
cout << "I don't crash" << endl;
return hold; //return the pointer to the new array
}