Thank you, I now changed the code of that function to this:
Code:
string *deleteEntry(string *dynamicArray, int &size, string entryToDelete)
{ int stop;
// create a new dynamic array 1 element smaller than dynamicArray
string *newArray = new string[size - 1];
// copy all elements from dynamicArray into new array
for(int i = 0; i < size - 1; i++)
{
if(dynamicArray[i]!=entryToDelete)
newArray[i] = dynamicArray[i];
else
{stop=i;
for(int i = stop; i < size-1; i++)
newArray[i] = dynamicArray[i+1];}
}
size--;
// delete dynamicArray
delete [] dynamicArray;
// and return the new array
return newArray;
}
I no longer get the error, but I now have a new problem. It deletes the entry and put the next entry in place of it like I want it to, but then prints that same entry one more time, like if had i had 12345 before and want to delete 2, I have 1334, when I want 1345. Please help me out.