UMBC CMSC202, Computer Science II, Spring 1998, Sections 0101, 0102, 0103, 0104 and Honors

Project 1

Due: Wednesday, February 11, 1998


The objective of this assignment is to practice working with structures and to learn binary file I/O using the fread() function.


Locate the four binary data files in the directory ~chang/pub/cs202/proj1/ named SF_Adventure.rec, SF_General.rec, SF_High_Tech.rec and SF_Short_Stories.rec. Each file contains a set of records in binary format written using the fwrite() function. Each record in the file contains information about a book and has the following type: typedef struct { char title[81] ; char author[41] ; short kind ; short year ; float price ; } book_t ;

The title field contains the title of the book and the author field contains the name of the primary author. The kind field has value 1, 2 or 3, representing respectively whether the book is a paperback, a hard cover or an audio "book on tape". The year field stores the year that the book was published and the price field contains the price of the book.

Your assignment is to write a program that allows a user to search these files for books that fit some user-specified criteria. Your program should allow the user to direct the search in just one of the four files or in all four files. The user should be able to select books based on the title, the author or the price. When the selection is by title or by author, a book is considered a match if the string specified by the user is a substring of the title field or the author field. For example, if the user enters "Asimov", then the book titled "Isaac Asimov : The Complete Stories Vol 1" should be selected in a search by title. In search by price, a book with a price less than that entered by the user should be considered a match. Your program should print out the information on the books that were selected by the user's search.

Programming Notes

Turning in your program

Please include the following statement in the comment section of your program:

I have read and I understand the course policy on cheating. By submitting the following program, I am stating that the program was produced by my individual effort.

You will turn in your program using the UNIX submit utility -- details will be announced shortly. For this project, please keep all your functions in one file. Create a transcript of running your program using the script utility. You should choose examples that demonstrate the correctness and robustness of your program. Submit only your source code and the transcript.

Late Policy Reminder

This project is due by midnight (1 minute after 11:59pm) on Wednesday, February 11, 1998. We will use the system clock as the final arbiter of time and date. If you turn in your project on time, you will receive a 5% bonus on your project grade. There is a grace period of 2 days, but after midnight on Friday, February 13, no more projects will be accepted.

Last Modified: 23 Mar 1998 13:08:14 EST by Richard Chang

Back up to Spring 1998 CMSC 202 Section Homepage