C++
COEN 244 (Summer 2015) - Assignment 4 Deadline: August 4th 11:59PM Type: Individual Assignment Weight: This assignment is worth 5% of your final grade Note: The assignment must be submitted on Moodle. Submission format: Create only ONE zip file (.gz, .tar, .zip are acceptable. .rar file is NOT acceptable) that contains all the header files, cpp files and test files. The name of the file must follow the template below: [student_id]_A4.zip or [student_id]_A4.tar or [student_id]_A4.gz Submissions do not follow about format should be responsible for the consequences. Problem: Write a function that reads from a sequential file and writes to another sequential file. The file path and name are passed through arguments of the main function. int main(int argc, char *argv[]) For example, the file name is ‘config.dat’ and the path is the current directory. The schema of the file is shown below.
The function should read the file, one record at a time. Each record has exactly 3 fields. The first field (call it: dType) contains the string: int, float or char. The second field (call it: dSize) contains an integer number. This integer is equal to the number of elements in the third field. The third field (call it: dSeq) contains a dSize number of dType elements (e.g. 12 integers, as shown below).
Each record can be stored into one of the following arrays depending on the type of the field,
int *iPtr; float *fPtr; char *cPtr;
Write out each record with the data in reverse order to a file named “reverse.dat” in the current directory, following the same schema. For example, the above example should be written as int 12 0 7 9 3 4 3 6 8 1 9 1 float 2 56.31 5.30
int 12 1 9 1 8 6 3 4 3 9 7 0
chat 6 z o K y a h float 3 10.11 22.41 5.55 Exceptions should be thrown out and handled. Notes:
• The solution should be general to processing any file with the same schema, not only applicable to the given file example.
• The program will be tested with data files with the same schema. Assignment Marking Scheme:
• Program correctness (75%) • Program output format, clarity, completeness, and accuracy (10%) • Program indentation and readability (5%) • Choice of significant names for identifiers (5%) • Comments - description of variables and constants (5%)