I've been given an assignment which asks me to write a program that does the following:
-Opens a file which contains 50 last names and student IDs
-Gives the user the option of searching by last name or ID
-If there is a match, both the name and ID will be printed.
-If there is no match, an error statement is printed.
I know how to get the program to open a file, but I'm not sure what to use for searching the file for a name. Any suggestions?
Do you know the exact format of the file, for example:
yes, its like
So read in the data into a data structure of your choosing (if it's always 50, then that suggests an array; if it's not always 50, then you'll probably want something dynamic); then as your user requests searches, you can search through the data structure to find the results.