Your program will mimic a phone book. You will be given a file. In the file is a set of names and phone numbers (an entry). There will be one item per line, 3 items per entry, you don’t know how many lines are in the file. You are guaranteed at least one entry.
Your program will be menu driven.
Your task is to accept an index number, last name, a first name or a phone number from the user and to read through the text file, looking for a match. If match(s) are found, display the information, and then redisplay the menu.
If the entry was not found display the appropriate not found message. All search results, including the index of the entrie(s) will be written to the screen. You are guaranteed that when you ask for input you will get the appropriate type – not necessarily within range – but the right type.
You must store each entry in a struct that contains three strings: one for the first name, one for last name and the third for a phone number. The structs will be collected into an array of that type.
INPUT FILE FORMAT
The input file will contain entries. There will be one item per line, all lines in the file end with a carriage return. Here is a sample input file for clarification:
Steiner Stuart 509-359-6260
Smith Brandon
509-359-6260
Roestel Stacey
509-359-6260
Capaul Tom
509-359-6260
Steiner Darren
509-888-7676
SAMPLE OUTPUT
My Contacts File Program
Please choose from the following:
1) Look up a contact by last name
2) Look up a contact by first name
3) Look up a contact by phone number
4) Look up a contact by index (zero-based)
5) Quit
Choice –> -3
I am sorry that is not a valid menu choice.
Please try again
Please choose from the following:
1) Look up a contact by last name
2) Look up a contact by first name
3) Look up a contact by phone number
4) Look up a contact by index (zero-based)
5) Quit
Choice –> 1
Please enter the name you would like to search for: steiner
The information for Steiner is:
Stuart Steiner
509-359-6260
Darren Steiner
509-888-7676
Please choose from the following:
1) Look up a contact by last name
2) Look up a contact by first name
3) Look up a contact by phone number
4) Look up a contact by index (zero-based)
5) Quit
Choice –> 1
Please enter the name you would like to search for: peters
The information for Peters is:
No entries found for that information;
Please choose from the following:
1) Look up a contact by last name
2) Look up a contact by first name
3) Look up a contact by phone number
4) Look up a contact by index (zero-based)
5) Quit
Choice –> 5
Thanks for using your CSCD255 white pages.