Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void findCustomer(Customer *arr, int size)
- {
- //usrchoice is for redoing the search if nothing is found with first try
- char usrchoice = 'n';
- int id = 0;
- //customer id stores the id value of the customers that match the search
- vector<int> customerid;
- do
- {
- //delete previous input from usrchoice or from initiating the function
- cin.ignore();
- cout << "Enter the customers first or last name: \n";
- string search;
- getline(cin, search);
- //found is used to identify if a match has been found to end the loop
- bool found = false;
- while (id < size)
- {
- if (arr[id].name.find(search, 0) != std::string::npos)
- {
- customerid.push_back(id);
- found = true;
- }
- id++;
- }
- if (found == false)
- {
- cout << "No accounts with that name could be found.\n";
- cout << "Do you wish to try again?\nEnter y for yes and n for no.\n";
- cin >> usrchoice;
- }
- else
- usrchoice == 'y';
- } while (tolower(usrchoice) == 'y');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement