Question: Task Matrices in a binary file A binary file named matrices.bin contains a list of 4 matrices (two-dimensional arrays). Each matrix in the file is
Task Matrices in a binary file
A binary file named "matrices.bin" contains a list of 4 matrices (two-dimensional arrays). Each matrix in the file is codified in the following format: its alphanumerical name, as a string its number of rows, as a 32-bit unsigned integer its number of columns, as a 32-bit unsigned integer all its elements, as 32-bit signed integers The number of matrices in the file will always be 4. Implement a C++ program that: reads the file "matrices.bin" and stores each matrix in memory, along with their names and sizes creates a text file named "results.txt" to write the following information for each matrix: o name of the matrix o memory address of each row of the matrix In the file "results.txt", the matrices should be stored in alphabetical order based on their name. Assume you have enough resources in your system to store the content of the file "matrices.bin" in RAM this means, you can store the whole file at once and you dont have to use nothrow or exception handling to verify if the allocation was successful. Requirements: you should divide the problem into functions and you should not use global variables. Hint: the string class provides overloads for the comparison operator
Example: Matrices in the binary file "matrices.bin": name = "Cpp", rows = 2, cols = 1 1991 15 name = "145", rows = 4, cols = 3 1 -23 45 111 14 32 -999 156 200 3 132 176 name = "Bm", rows - 2, cols - 3 1-31 14 5 6771 32 -999 name = "DxXxx", rows = 3, cols - 2 1 451 113 51 67 -18 Output in the text file "results.txt": NAME: A45 ADDRESS OF ROW : 0x7fd1615041a0 ADDRESS OF ROW 1: 0x7fd1615041a8 ADDRESS OF ROW 2: Ox7fd161504160 ADDRESS OF ROW 3: Ox7fd161504158 NAME: Bm ADDRESS OF ROW O: Ox7fd161504200 ADDRESS OF ROW 1: Ox7fd161504208 NAME: Cpp ADDRESS OF ROW @: @x7fd161504170 ADDRESS OF ROW 1: 0x7fd161504178 NAME: DXXXX ADDRESS OF ROW @: @x7fd161504230 ADDRESS OF ROW 1: Ox7fd161504238 ADDRESS OF ROW 2: @x7fd161504240 Value: 80/100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
