Assignment Instructions

  1. Edit, compile, and run the following programs on the UH UNIX shell:
    1. Create the "students.data" random access file by running the program creating.c
    2. Create the content of the "students.data" file by running the program writing.c
    3. View the "students.data" file by running the program reading.c
    4. Write a program that edits the "students.data" random access file.
    5. The program displays all the records, asks the user which record they want to edit, asks the user what fields to change in that record, and then change only those particular fields.
    6. Email your makefile and C program to the instructor, or show it to the instructor in class.
  2. For the submission guidelines and the grading guidelines, see the syllabus.

Example I/O

The user input and output is up to you. Make sure it is easy to understand, and has error checking. Below is an example, but you can do things differently if you wish as long as the user can edit the data somehow.


Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0      Bubba     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Enter the record number you wish to edit: -3
ERROR: No negative numbered records exist!

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0      Bubba     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 3
ERROR: Records #3 does not exist!

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0      Bubba     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 30
ERROR: No records 20 or above exist!

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0      Bubba     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 0
You selected record #0:
     0      Bubba     Smith   20  2.2  
Do you wish to edit first name (f), last name (l), age (a), or gpa (g)? b
ERROR: 'b' is not a valid answer!

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0      Bubba     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 0
You selected record #0:
     0      Bubba     Smith   20  2.2  
Do you wish to edit first name (f), last name (l), age (a), or gpa (g)? f
Enter first name: Hoss

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0       Hoss     Smith   20  2.2  
     1      Sally    Suzuki   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 1
You selected record #1:
     1      Sally    Suzuki   29  3.3  
Do you wish to edit first name (f), last name (l), age (a), or gpa (g)? l
Enter last name: Honda

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0       Hoss     Smith   20  2.2  
     1      Sally     Honda   29  3.3  
     5     Surfer      Dude   40  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 5
You selected record #5:
     5      Surfer      Dude   40  4.0  
Do you wish to edit first name (f), last name (l), age (a), or gpa (g)? a
Enter age: 39

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0       Hoss     Smith   20  2.2  
     1      Sally     Honda   29  3.3  
     5     Surfer      Dude   39  4.0  
Keep editing records? Yes(y) or No(n)? y
Enter the record number you wish to edit: 5
You selected record #5:
     5     Surfer      Dude   39  4.0  
Do you wish to edit first name (f), last name (l), age (a), or gpa (g)? g
Enter gpa: 3.9

Number  FirstName  LastName  Age  GPA  
------  ---------  --------  ---  ---  
     0       Hoss     Smith   20  2.2  
     1      Sally     Honda   29  3.3  
     5     Surfer      Dude   39  3.9  
Keep editing records? Yes(y) or No(n)? n
The file "students.data" was successfully updated.