Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. void findCustomer(Customer *arr, int size)
  2. {
  3. //usrchoice is for redoing the search if nothing is found with first try
  4. char usrchoice = 'n';
  5. int id = 0;
  6. //customer id stores the id value of the customers that match the search
  7. vector<int> customerid;
  8. do
  9. {
  10. //delete previous input from usrchoice or from initiating the function
  11. cin.ignore();
  12. cout << "Enter the customers first or last name: \n";
  13. string search;
  14. getline(cin, search);
  15.  
  16. //found is used to identify if a match has been found to end the loop
  17. bool found = false;
  18. while (id < size)
  19. {
  20.  
  21. if (arr[id].name.find(search, 0) != std::string::npos)
  22. {
  23. customerid.push_back(id);
  24. found = true;
  25.  
  26. }
  27.  
  28. id++;
  29. }
  30.  
  31. if (found == false)
  32. {
  33. cout << "No accounts with that name could be found.\n";
  34. cout << "Do you wish to try again?\nEnter y for yes and n for no.\n";
  35. cin >> usrchoice;
  36. }
  37. else
  38. usrchoice == 'y';
  39.  
  40.  
  41. } while (tolower(usrchoice) == 'y');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement