Link back to syllabus

Write a directory program. The program should start by reading in the file roster.txt (see below for information about reading files). Then, allow the user to type in a search string, printing out information about every student whose name matches.

First, define a struct person that stores 4 fields: - a first field, which is a string capable of holding at least 20 characters - a last field, which is a string capable of holding at least 20 characters - an email field, which is a string capable of holding at least 30 characters - a at_bryn_mawr field, a bool

Then, write a loop that reads in information about students from "roster.txt", into an array of 32 of the struct you wrote. Check out the file to see its format: a student’s last name comes first, followed by their first name, followed by their email address. You can tell if a student goes to Bryn Mawr by looking at the email address. Your loop should fill in the details of the 32 students in our class.

After the info is read in, then ask the user to type in a query. Your program should print out information about students whose names (either first or last) match the query. For example:

Whom do you want to look up? ha
Lizzy Chan (lmchan@brynmawr.edu) is a student at Bryn Mawr.
Arthur Chang (ajchang@haverford.edu) is a student at Haverford.
Ilisha Ramachandran (iramachand@brynmawr.edu) is a student at Bryn Mawr.

You can read a file using fgets. Note that the last argument is a FILE*, which you can get from fopen. If roster.txt is in the same directory as your C program, it should all work.

Make sure that your program reads user input safely. That is, if the user types in a very long query, that should not crash your program.