Question: Lab Task 2 Text File Input of Doom (An exercise in file processing) Textbook Reference: Chapter 12 Your boss at Mazes for Mice has decided

Lab Task 2 Text File Input of Doom

(An exercise in file processing)

Textbook Reference:

  • Chapter 12

Your boss at Mazes for Mice has decided that having to input the maze data via the keyboard is far too slow, especially for companies (such as the one in which Microsofts employees work) that use large mazes.

Instructions:

Open a new Visual Studio project. Open a new C++ source file. Write a program that inputs the data below from a text file and then outputs it to the screen. Remember to #include at the top, and then to declare your ifstream object. Also remember to create the file (perhaps in Notepad) and include it in your project. The input will terminate when it reaches a zero (0), but it will not display this character. You may assume the maze will be no larger than 10x10. The input will be as follows, with the M indicating the current position of the mouse.:

Input: (just use Notepad to create this file and remember to include the zero (0) ).

# # # #

# M # #

# . . #

# # . #

# . . #

# # # #

0

Output you should get:

# # # #

# M # #

# . . #

# # . #

# . . #

# # # #

When the program works, simply initial the Task 2 space on the cover sheet.

Lab Task 3 Text File Input/Output of Doom

(An exercise in file processing)

Textbook Reference:

  • Chapter 12

Your boss at Mazes for Mice has decided that having to output the maze data to the screen is way too costly. You are now to output to a separate text file instead of the screen. Remember you can do this by declaring your ofstream object and then using it like you do ifstream objects, but with the redirection arrows (<<).

Instructions:

Open a new Visual Studio project. Open a new C++ source file. Write a program that inputs the data below from a text file (use the same file you did in Task #2) and then outputs it to a second text file. Remember to #include at the top, and then to declare your ifstream and ofstream objects. Also remember to place a copy of the input file in this new workspace and include it in your project.

The input will terminate when it reaches a zero (0), but it will not display this character. You may assume the maze will be no larger than 10x10.

Input: (just use the input file from task 2 and remember to include the zero (0).

# # # #

# M # #

# . . #

# # . #

# . . #

# # # #

0

Output you should get:

# # # #

# M # #

# . . #

# # . #

# . . #

# # # #

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!