CMSC 246 Systems Programming
Fall 2019


Assignment #5 : Structs and Airports
Due: October 25: 11:59 PM Due: Oct 27: 4:59:59 PM

Write a program that, given a database of all US airports, enables a user to search for airports by their code. Here is a sample output from such a program ()

UNIX> ./airportsearch /home/gtowell/Public246/HW05/code.txt
Able to open file: code.txt
Reading data...done [3376 airports!]

Enter the three-letter code for an airport: PHL
Success: PHL - Philadelphia Intl, Philadelphia PA (USA)
Would you like to search again (Y/N)? Y

Enter the three-letter code for an airport: LHR
Unsuccessful: LHR is not a know airport.
Would you like to search again (Y/N)? Y


Enter the three-letter code for an airport: 06U
Success: 06U - Jackpot/Hayden, Jackpot, NV (USA)
Would you like to search again (Y/N)? N
Goodbye!

Above, underlined text is user input.

Requirements:
  1. Your program should take 1 command line argument, the name of the data file to be read
  2. Data is in the file /home/gtowell/Public246/HW05/code.txt. Although unlikely to change, your program must be able to read from whatever file is specified on the command line, NOT just this file.
  3. You may assume that the data file will follow precisely the format of the one named above. You may also assume that the data file has less than 4000 entries.
  4. Data about each airport must be stored in struct(s)
  5. The airport file should be read only once.
  6. When reading ignore the first line of the data file
  7. The struct you create should store the following information: iata (aka code), airport, city, state, country. The following are the max sizes for each field:
  8. iata,airport,city,state,country appears on each line, comma separated, in the data file. You may parse lines in the file using either strok or sscanf.
  9. Perform a simple linear search to look for an airport.
  10. Use good design principles to design your program (think OOP design, but apply it to the design of this C program).
Sample output: Once done, show your program's output for the following inputs: BMC, 172 (One Seven Two), 00M (Zero Zero Em), TCS, BUZ, 5A8, DAR, ZZV, 22M, PHL.

Scripting in Linux
Once done, you will need to show the sample runs of programs, as required. In order to record the runs, you can use the Linux command script.
Go to your Assignment directory and enter the command: script session

You will get your command prompt back. Next, run each of the above programs as you normally would. Once done, enter the command: exit (or CTRL-D)

This will end your script session. If you now look a the contents of the session file, you will see that the entire interaction has been recorded in it (as a script!).

What to submit:

Collect together is a single directory all of the following: When you have everything ready in this directory go to the directory containing the one with the information you want to submit. For instance, suppose that the files specified above are in /home/YOU/cs246/aN. (For this assignment N=5.) Then you should go to /home/YOU/cs246.
Use the submit program as follows:
  /home/gtowell/bin/submit -c 246 -p N -d aN
This will package up everything in the directory aN and submit it under your login name along with a timestamp of your submission date.

Back to CMSC246 Home page