Advertisement
homeworkhelp111

salesDelete

Apr 27th, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. void salesDelete(Sales sales[], int* numRecords) {
  2. printf("DELETE SALES RECORD\n");
  3.  
  4. char SalesOrderID[SALES_ORDER_ID_SIZE];
  5. GetSalesOrderID(SalesOrderID);
  6.  
  7. int recordCount = 0, found = 0;
  8. struct Sales oldRecord[1];
  9. while (recordCount < *numRecords) {
  10. if (strcmp(sales[recordCount].SalesOrderID, SalesOrderID) == 0) {
  11. oldRecord[0] = sales[recordCount];
  12. found = 1;
  13. DisplaySalesInformation(oldRecord, 1);
  14. break;
  15. }
  16. recordCount += 1;
  17. }
  18. if(found == 1){
  19. for(int i=recordCount; i<*numRecords-1; i++){
  20. sales[i] = sales[i+1];
  21. }
  22. *numRecords = *numRecords - 1;
  23. writeToFile(sales, *numRecords);
  24. printf("Record has been deleted, successfully!\n");
  25. }
  26. else {
  27. printf("Record does not exist!\n");
  28. }
  29.  
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement