You must create a program which loads the file observations.txt and creates a binary file of records containing the valid entries called valid.dat and a text file called errors.txt which contains the entries that do not follow the rules in the same format as the original text file. The records must have alignment padding disabled.
Hi ,please help ,the information below is the entire question.
File Handling in C++
The Utopian Astronomical Society (UAS) is collaborating with observatories all around the
world to gather a weeks worth of intensity observations of the same variable star which they
believe may be about to become a supernova.
The UAS has recently heard about the advantages of random access files of records and would
like you to create a program which will convert their old text based observation files into a new
binary format.
• Each line in the text file represents an observation data set, each datum is separated
by a space, the values are as follows in the order below:
An observation ID in the following format: An observation ID starts with an
uppercase letter then contains any combination of upper case letters, numbers,
and hyphens “-“. The ID may not end on a hyphen. The maximum length is 16
characters.
A valid ISO 8601 date (i.e. a date in the YYYY-MM-DD format).
A sequence of up to 7 integer values in the range [0, 100]
Not all of the entries in this file will follow the rules.
You must create a program which loads the file observations.txt and creates a binary file
of records containing the valid entries called valid.dat and a text file called errors.txt
which contains the entries that do not follow the rules in the same format as the original text
file. The records must have alignment padding disabled.
output sample
I-978-213 2020-01-02 10 5 20 33 54 20
BV-123-433 2020-05-02 23 12 22 12 20
OP-VG3-712 2020-07-02 5 1 67 22
12-DF-11 2020-04-03 1 2 3 4
GH-I-12- 2020-08-12 2 29 83 99
JK-ILM-20 2020-99-12 1 2 3
JJ-GSM-20 2020-09-12 1 2 3 4 5 6 7 8
TT-JJJ-1983 1983-01-01 50 75 80 65 50
saved as observation.txt
Step by step
Solved in 2 steps with 6 images