Question: C++ HELP!!! (CHECK REQUIREMENTS) You will make a 2D array of 13 columns and 2 rows of type char. char theArray[13][2]; will work to create

C++ HELP!!! (CHECK REQUIREMENTS)

You will make a 2D array of 13 columns and 2 rows 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 lab8.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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!