Question
C++ a program to implement a simple address book that stores phone numbers, names, and addresses and allows the user to look up an entry
C++ a program to implement a simple address book that stores phone numbers, names, and addresses and allows the user to look up an entry based on any of them. After each lookup the program should ask the user if they want to look up another until they are done. The file should be structured so that a person's first name, last name, and phone number are stored on one line separated by commas and the next line has their address. (Note: The program does not need to create the file, just read an already existing file.) I'm having trouble reading the file and outputing the correct results.
heres one of my functions:
string getName(ifstream inData) { string firstName; string lastName; string address; string number; string filename;
inData.open(filename.c_str());
while (inData) { inData >> firstName >> lastName >> number;
inData>>address>>endl;
} while (!inData) // If name is not in the directory { cout << "Name is not in directory. Please try again." << endl; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started