This lab will help you practice with file processing and string processing.
Take the contact searching program developed in lecture and its associated data file as a starting point.
Enhance this code to not use == to test for a match but rather do a case-insensitive substring match instead. (Tip: This will be like that other lab mixed with string::find.)
What arguments does your matching function take? Are they changed? What special care should you take with them?
What value is returned by your function? What type is it and what does it represent?
What care does a caller of your function have to take with this return value? (i.e. Can they immediately assume it is a valid index?)?
This assignment is (Level 2.5).
Add (Level 2.5) to put two-three pieces of contact information along with the contact names in the file. Then make a class to store all of the contact info with a nice read method to pull it in from an input stream — cin or a file!
Where your current search loop has a simple getline of the contact_from_file, you'll have:
contact_object.read(contacts_file); contact_from_file = contact_object.get_name();
Add (Level 2) to store all matches in a vector instead of immediately printing them to screen. Then, at the end of the while(good) loop, you can print all the matches or report there weren't any based on the vector's empty status.
If you took the class option above, you can add another (Level 2) to provide them a menu of matches from which to pick whose contact info they want to see when there were multiple matches.