Laboratory 7: Handling Variable-Length Records and Formating Output
In this lab, you will learn
how to manipulate records in a file with variable-length records.
You will learn how to jump
to a certain record (using its RRN) in order to
read it; the records begin
with a length indicator which should be used
to skip through records
The first record has RRN=0,
the second has RRN=1, and so on.
In addition, you will learn
how to use c++ formating methods to create a report.
Methods to be reviewed by your TA.
Task: Read the records of the file and write them
into another file by using the specified report format
Download the following files:
Create an empty project (lab7) and include the downloaded file lab7.cpp.
Include the code for the function readRecordbyRRN(int, istream&):
Your code should read the right record to a string according to the RRN
Include the code for the function writeRecord(string, ostream&):
Your code should write this record in the output file with the report format
Use Record Format and Report Format specifications described
below in your implementation
Compile and run the project
Look at the newly created report file, it should look exactly as in Report
XX = record length
| = field separator
FIRST NAME MONTH DAY YEAR
----- --- ---- <-------
Bill Out 13
Sabrina Feb 11 1970
Ashley Dec 30 1974
Billy Nov 07
Scott Jun 28
John Dec 12
Anthony May 29 1969
Michel Feb 22 1970
James Dec 17
<---> <-> <-->
5 3 4 (lengths in output_lengths