I need to remove an element from my profile[] array, then move back all other elements in the array to fill in the now empty space. This is my attempt at doing the first part of the problem, gives a -fpermissive error, Advice?
void deleteCreature(int numCreatures, Creatures profile[])
{
for (int x = 0; x < numCreatures; x++)
{
cout << "The following is a list of all the creatures you take care of:"
<< profile[x].name << endl << endl << endl;
cout << "What creature do you wish to remove?" << endl
<< "CREATURE NAME: ";
cin.ignore();
getline(cin, profile[numCreatures].name);
std::vector<int> array;
auto it = std::find(array.begin(), array.end(), profile[numCreatures].name);
if (it != array.end())
{
array.erase(it);
}
else
{
std::cerr << "Could not find profile!\n";
}
cout << "You have removed " << profile[x].name << "." << endl << endl;*/
}
}
EDITED
profile[x]instead ofprofile[num]in your loop?deleteis a C++ keyword. You can't use it as the name function or variable. Choose a different name.