Question: Create a new file named: CustomerDB. t x t . A customer data file contains a list o f customers ( o n e per

Create a new file named: CustomerDB.txt. A customer data file contains a list of customers (one per line), each customer consisting of a unique customer id followed by a first and last name.
42 Mike Jones
16Al Garcia
27 Sarah Lee
12 Stan Lee
99 Amy Hernandez
Ask the user to enter the idto find.
As you read from the file, search for the id
If found, output the customer's info as Customer id#: Last, First
If not found, output Not Found
what I have:
#include ??std::ifstream
#include ??std::cin, std::cout
#include ??std::string
int main(){
std::string idToFind;??Using string for idin cases of both numbers and letters, like M47
std::cout << "Enter ID: ";
std::cin >> idToFind;
std::string dbId;
std::string dbFirstName;
std::string dbLastName;
std::ifstream fin;
fin.open("CustomerDB.txt");
if(!fin){
std::cout <<"
Error opening file for reading
";
return -1;
}
while(! fin.fail()){
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!