Alright I'm close to getting the right solution for deleting a record from a file. It is finding the file to delete but instead of completely getting rid of the record and not seeing it anymore, it is displaying the deleted record as a bunch of weird characters in the file.
Here is my code for the section on deleting a record:
Code:
// delete a product from the inventory
case 'd':
system("cls");
cout << "Enter product ID number of the product you
wish to delete: ";
cin >> delnum;
cin.ignore();
// for all records in the file
for (j = 0; j <= p; j++) {
// if the Product ID number entered by user matches a
Product ID number in the file
if (delnum == Product[j].get_id()) {
Product[j] = Product[j+1]; // delete record
cout << "\nProduct has been deleted. Press any key
to return to main menu.";
break;
}
}
getche();
system("cls");
break;
Can anyone see what I need to change in order to remove the record so that I don't see those strange characters in the spot of the deleted record?