CMSC 246 Systems Programming
Spring 2018
Assignment#6
Due in Class on Monday, March 26, 2018
- Airports!
Write a program that, given a database of all US airports (see details as well as how to get the data file from Lab 8), enables a user to search for airports by their code. Here is a sample output from such a program (called search.c)
[Xena@codewarrior] $ ./search 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: PHL 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.
You will make use of the following from this week's lab:
1. File I/O (using FILE, fopen(), fclose())
2. Command line arguments (see example above)
3. Using strtok() to parse the CSV file.
4. Your main data structure will be an array of airports (define a structure type Airport). Here are the limits you may use: No more than 4000 airports, no more than 5 letters in airport code and state name, no more than 50 letters in airport name, and no more than 30 letters in city and country name.
5. You will perform a simple linear search to look for an airport.
6. 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 below. 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 hand in:
- A printout of all the program files.
- A prinout of the script file showing runs of your program for exactly the inputs specified above.
- Write and print out a short 1/2-paragraph reflection on your thoughts on this lab (how this assignment went for you, what went wrong, etc.)
- Answer the following in your write up:
- How many airports in the database are not in the US? Give at least one example.
- Why did we specify a limit of 30 chars for country name?
- How would you determine the limit on the number of airports for your program's data structure?
Back to CMSC246 Home page