Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ This is my second time asking this question because you are copying the answer from chegg even though I stated it explicitly. PLEASE DO

C++ This is my second time asking this question because you are copying the answer from chegg even though I stated it explicitly. PLEASE DO NOT POST THE SAME ANSWER. DO THIS ASSIGNMENT WITH ATTENTION TO WHAT IS REQUIRED. I ADDED THE OUTPUT WE NEEDED TO ACHIEVE. WRITE THE CODE I WILL OBTAIN THIS OUTPUT.

matrices.bin file contains 4 matrices:

  • 24 bytes of string
  • 4 bytes of unsigned int for number of rows
  • 4 bytes of unsigned int for number of cols
  • 4 bytes of int for each element of the matrix

If your environment implements the class string with more (or less) than 24 bytes, you must create your own binary file containing the 4 matrices in order to try your software.

image text in transcribed

image text in transcribed

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. matrices.bin name cols name rows cols elements elements elements elements name u cols name rows cols 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 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 don't 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 operators. Example: Matrices in the binary file "matrices.bin": name e - "Cpp", rows - 2, cols - 1 1991 (151 name = "445", rows - 4, cols - 3 1-23 45 11 14 32 -999 56 200 31 32 176 name = "Bm", rows - 2, cols - 3 1-31 14 5 6771 32 -999 name = "DXXXX", rows - 3, cols - 2 1 45 113 51 167 -18 Output in the text file "results.txt": NAME: A45 ADDRESS OF ROW @: @x7fd1615041a ADDRESS OF ROW 1: @x7fd1615041a8 ADDRESS OF ROW 2: @x7fd1615041be ADDRESS OF ROW 3: ex7fd1615841b8 NAME: Bm ADDRESS OF ROW @: @x7fd161504200 ADDRESS OF ROW 1: @x7fd161504208 NAME : Cpp ADDRESS OF ROW @: x7fd161504170 ADDRESS OF ROW 1: Ox7fd161504178 NAME: Dxxxx ADDRESS OF ROW @: @x7fd161504230 ADDRESS OF ROW 1: Ox7fd161504238 ADDRESS OF ROW 2: @x7fd161504240

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Write out the sum. k=0 3k

Answered: 1 week ago