I need help asap

i have this assignment to submit tonight by 4 am, and i have been working on it for the past days, only have 6 weeks to learn ebverything prof is bad aand her notes even worst, i really need help if anyone can help me please

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.
Where is your work so far? Surely you have managed something over the past days.
I think the instructions are pretty good, much better than some I have seen so what are you having trouble with ?
Each record can be stored into one of the following arrays depending on the type of the field,
1
2
3
int *iPtr;
float *fPtr;
char *cPtr;

these are pointers, not arrays...
And yes, I know that you can allocate space and use it like an array but pointers are not arrays.
Why is it so hard to teach proper c++?
It feels like people say c++ and mean c with the c98 standard...

Here you go, C++03 and C++11 dynamic memory management
1
2
3
4
5
6
7
8
#include <vector>

int main(int argc, char* argv[])
{
    std::vector<int> integers;
    std::vector<float> floats;
    std::vector<char> chars;
}



Well, whatever, what have you got over the past days?
Last edited on
Topic archived. No new replies allowed.