The Creighton University home page includes a search engine for finding a student or faculty member's phone number and email address. This is an example of a Web-based client/server application. Using a Web-browser (the client), you can access a remote database of student/faculty information through a CGI program that works in conjunction with the Web server.
This assignment is the first step in developing a similar, albeit simplified, search engine. You must design and write a C++ program that reads the name (or partial name) of a person and searches for that name in a file of email addresses. Your program should then display the names and email addresses of all people whose names match. Since this program will eventually be connected to a Web server and accessed via a Web page, there are very specific requirements on the form of the input and output of your program.
"search=Dave" "find=Dave+R"
The first input string specifies that all names containing the letter sequence "Dave" should be reported. Note that the letter sequence may appear anywhere in a name and case is not relevant. Thus, a search for "Dave" might find "Dave Reed", "Davender Malik", and even "Chris Muldavey" (if such a person existed). The second input string requires a match for "Dave R", thus ruling out "Davender Malik" and "Chris Muldavey".
Jim Carlson carlsn@creighton.edu Davender Malik malik@creighton.edu Premchand Nair psnair@creighton.edu Dave Reed davereed@creighton.edu Mark Wierman wierman@creighton.edu
Content-Type: text/html
There should then be a blank line, followed by one line of output for each matching name (with <BR> at the end). For example, given the email.txt file above, the input string "lookfor=Dave+R" should yield the following output:
Content-Type: text/html Dave Reed: davereed@creighton.edu
Similarly, the input string "find=RE" should yield the following output:
Content-Type: text/html Premchand Nair: psnair@creighton.edu
Dave Reed: davereed@creighton.edu
If no name matches the input string, then a message to that effect should be displayed. For example, the input string "name=foo" should yield the following output:
Content-Type: text/html No match found
Since this program involves parsing a string of text, ignoring case, and searching a data file, I strongly recommend that you consider using the <string>, <cctype> and <fstream> libraries that are standard in C++. You may refer to a C++ text or online resources for a review of the classes and functions defined in these libraries. For quick tips on these and other useful libraries, see my handout.