When interacting with scientific data sets, it is useful if a program can extract from the data set, information about the data set. The name for such information is meta-data - data about the data set. Many data sets in use throughout the scientific community contain meta-data that describe what is to be found in the (normally binary) file. For instance, the size and type of data could be in the file as well as additional info such as the lon/lat of the data, the date the data was generated and even the ship and equipment identification. Meta-data is widely used with all types of data (including databases).

A data file could contain for instance, sea surface temperature, salinity, and sea surface height. All 3 may be present in different quantities or only 1 or 2 (of the 3) may be in the file. Meta-data can tell us which data sets are present and the sizes. Of course some data storing conventions should be used so that a program can read any valid data set. For our example data, we can have (and in the order listed) sea surface temperature, salinity, and sea surface height. If we use a 1 to mean the data set is present and a 0 to mean it is not and follow that with the data set size:

1 1 0 40

would me we have sea surface temperature and salinity but not sea surface height. The size of the sea surface temperature data an the salinity data set is size 40.

0 1 0 40

would me we have only salinity in the file and the data set is size 40.

Your homework is as follows: write a program using the above conventions that will read any valid data set (of the 3 data types). After reading the data (which will be in binary), write the data to a file with the name:

dataType.size

where dataType is one of the three types and size is the size of the data set.

For the 2nd example above, the output file would be: salinity.40.

The input file name will come from the command line.

USE ERROR CHECKING.

There will be no white space (empty/blank lines). Comment your code and make it readable.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.