I am trying to delete the array element that matches with the user input. So I am trying to shift all the cells after the deleted one to the left 1 spot. I know it's still in the loop of the if statement(line 11 and 31) but I can't figure out how else to do it.
//Can't figure this out
void deleteID(inventory& inv)
{
char id[8];
cout << "Enter search value: "; cin >> id;
for (int index = 0; index < inv.total; index++)
{
if ((strcmp(inv.item[index].id, id)) == 0)
{
inv.item[index ] = inv.item[index + 1];
}
}
inv.total -= 1;
}
//Can't figure this out
void deleteName(inventory& inv)
{
char name[20];
cout << "Enter search value: "; cin >> name;
for (int index = 0; index < 9; index++)
{
if ((strcmp( inv.item[index].productName, name)) == 0)
{
inv.item[index] = inv.item[index + 1];
}
}
inv.total -= 1;
}