Programming Assignment 4
CMPS 352 Operating Systems
Fall 2009

Through this asssignment, you will learn how to access binary files and build indices. A company maintains its employee records in a file named employee.binwith the following data structure. Employee records are stored in the file with no particular order. You are asked to design a program that allows to add new employees to the file and change the salary of a given employee.

struct Employee {

    int empID;

    char first[15];

    char last[12];

    int age;

    double salary

};

Your program accepts an integer to indicate what operation is to perform as follows:

    1. Add a new employee record. The integer is followed by the info of the employee - empID, first, last, age, salary, separated by white spaces.
    2. Change salary. the integer is followed by empID and new salary, separated by white spaces
    3. Terminate the program.

To facitate search, you are asked to build an index file for the employee record file. The index file should be named employee.idx and it should a sequence of pairs of <empID, seq#>, where empID is the employee ID  and seq# is the sequence number of the record stored in in the employee record file. The first record has a seq# 0. To simplify this assignment, we limit employee IDs to the range from 1 to 100 and it is guaranteed that there is no duplicates.  employee.idx should be in binary format

Your program, when it starts, should search for employee.idx file. if it exists, use it. otherwise, your program should create it and build the indices. 

The program should continue until the user enters 3 as operation code to terminate it. 

You must email me your assignment from server1 or server2 (bi@cs.uofs.edu) with your source code file as an attachment. Your source file must be named as asgn4-yourUserID.c. For example, if your user ID on server1 is "unu", then your file name should be asgn4-unu.c. The subject of your email should appear like “CMPS352 Assignment 4 – Your first name then last name".

Correctly naming your file and following submission procedure is considered part of the assignment requirements.

Late submission results in a 7 point (out of 100) deduction for every 24 hour period after the deadline. Any submission later than 7 calendar days after the deadline will receive a grade zero for the assignment.

Student Input File:
      Student Binary file: student.bin
      Student ASCII file: student.asc

Help Links:

       FreeBSD system calls for file processing
       Reading the Command Line in C and Unix
       A sample program on stat
       How to write binary data to files
       How to read binary data from files
       Convert string to integer
    Test cases Link removed.