CS
3050, Spring 2007
Programming Assignment 5
Due May 16, 2007
Handling Records by RRN
In
this lab, you will learn
how to manipulate records in a file with fixed-length records.
You will learn how to jump
to a certain record (using its RRN) in order to read it or modify it.
The first record has RRN=0,
the second has RRN=1, and so on. The lab is based
on an assignment created by Lucia Moura at the
University of Ottawa.
- Topics to be review before you start:
YOUR TASK
- Download the following files:
Problem 1: Read the records of a file and
write
them into another file in reverse order (last file first)
- Include the code for the function InputPositioningByRRN(int RRN,
istream&
input):
- Your code should position the reading pointer in the right
record according
to the RRN
- Compile and run the project
- Look at the modified/newly created output file
Problem 2: Change the name of student in a specified
record
to a given name
- Include the code for the function OutputPositioningByRRN(int RRN,
ostream&
output):
- Your code should position the writing pointer in the right
record according
to the RRN
- Include the code for the function ModifyStudentName(int rrn,
ostream&
output, string newname). Your code should:
- Use the function OutputPositioningByRRN(int RRN, ostream&
output) to
seek to the appropriate student
- Seek to the name field
- Write the new name over the old one
- Be careful. You have to write a 21-char string and a new
line symbol
('\n' or endl);
- In order to test your code include a function call in main() to
change
the name of the student 5 (with RRN=4) in the newly created output file
to "New John Paul"
- Compile and run the project
- Look at the modified output file
Submit your files (lab5.cpp, student.h, student.cpp, and students.dat)
along with a script to the homework submission
system as Lab5.
A hard copy of your lab5.cpp (be sure your name is on it) should be
turned in at the beginning of class.