Question
* IN C++ * ********Can anyone help me make a header file with void read2D_Data (string input, string output)***** This lab will focus on 2D
* IN C++ *
********Can anyone help me make a header file with void read2D_Data (string input, string output)*****
This lab will focus on 2D arrays and how they store and retrieve information from them. It will have a simple command file that will help us read commands and check array locations
Details
In this lab you will make a 2D array of 13 rows and 2 columns of type char. char theArray[13][2]; will work to create the array you need to store the data.
The program will process a set of commands. The commands will be described below.
load - The first command will be a load command. The load command will be followed by a file to open. That file will contain a set of characters in a 13 x 2 grid that you are to read and store in the array. The load command will always be first and it will always be followed by a filename to open. For example
load data.txt
This would mean you create another ifstream object using the file name data.txt, so store that in a variable and open that.
location - The second command is the location command. The location command will be followed by 2 integers. The integers represent an x and y location in the array. The location given by the x and y may or may not be valid. You need to make sure that they are at least 0 and less then 13 for x and 2 for y. For example:
location 0 0 location 12 1 location -1 -1 location 13 2
The first two examples are valid and the last two are invalid.
Depending on what is stored in the first two locations you would get output like this:
0, 0: A 12, 1: z
For the last two you would get this output:
-1, -1: bad location 13, 2: bad location
So when the location is good, you output the coordinates and then the data that is there and when the location is bad, you output the coordinates then the words bad location. Note the comma between the x and y and the colon after the y coordinate.
Sample Input
If the input file contains this:
load test1data.txt location 12 1
And the test1data.txt contains this data:
2 Y 5 \ R { i e K E 0 = R l @ ^ [ , C p l t b { ] \
This is the output:
12, 1: \
Requirements
You must use the file lab9.h for the header.
In the header you must declare the function void read2D_Data( string input, string output );
In your cpp file you must implement the function and use a 2D array of characters of size 13x2.
Due
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started