Question: using C++ Write a function that reads from a sequential file and writes to another sequential file. The file path and name are passed through
using C++
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). int 12 1 9 1 8 3 4 3 9 7 0 Each record can be stored into one of the following arrays depending on the type of the field, int *iPtr; float *Ptr; char *cPtr; Date *dPtr; 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 char 6 z o K y a h float 3 10.11 22.41 5.55
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
