Homework 1 -- Random I/O in C

Preparation

Within your Computer Science home directory create a protected subdirectory for this assignment by typing the following commands:

Now copy some initial files for the assignment into this directory by typing the following commands:

This should copy four files into your directory.

The big picture

You are going to write a program to search a range of 16-byte records stored within a file for a specific key. The records are pretty simple. They consist of a

A definition of an appropriate C data structure for the record is shown below and can be found in your file btree.h.

typedef struct simpRec {
   char     name[12] ;
   int      value ;
} simpRecT ;

The not quite-so-big picture

The "user interface" for this assignment is already defined. It is implemented by a main routine stored in the file ezsearch.c that you copied into your directory. You should not need to modify this file to complete this assignment.

This main routine will "parse" command line options and then call a routine rangeSearch that you must write. A stub routine for rangeSearch has also been copied into your directory as rsearch.c. You'll be glad to know that you have Makefile to help you compile all this code so that an executable is stored in ezsearch.

The ezsearch program should be run as follows:

which directs that the begpos'th through endpos'th records of a file should be searched for a record with name key. By default, the file /usr/local/csci/343/testdata/prog01.bt is searched; however, you don't have to worry about that. The file will be opened before your rsearch routine is called.

Your part of the picture

Your routine rsearch has the following C-prototype:

The five arguments are

  1. the up-to-twelve character key,
  2. the opened file,
  3. the beginning position,
  4. the ending position,
  5. a buffer for storing the record

This is not hard. Only twenty lines of C code are required to complete the assignment.

Due dates and turning it in

At noon on Monday, 9 February, a script will be run to copy rsearch.c from your csci/343/home1 directory. This script will be run at noon for five consecutive days. Each day your rsearch.c is missing or fails to successfully solve the problem, 20% will be deducted from your grade for homework one.


Back to the CSCI 363 homework page
Back to the CSCI 363 home page