Question
Below is a small program that roughly represents a robot in a room. The room is defined in a two-dimensional array of characters. Objects in
Below is a small program that roughly represents a robot in a room. The room is defined in a two-dimensional array of characters. Objects in the room are stored as characters in the array named room that represents the room. For example, the location of the robot is stored as an R in the array. The walls of the room are stored in the array as a - for the top and bottom walls and as | for the side walls.
#include
The function named setup() stores all of the initial characters into the 2 dimensional array that represents the room. For this lab your task is to build the function named print() that prints the room to the computer screen. You will need to use the curses library to write your function that prints the room. A reference for the curses library appears on the course website. Your print() function should take the room array as an argument and should loop through the entire room array, moving to the correct location on the screen and printing the character stored in the array that is to appear in the room at that location. Look at the syntax of the setup() function to determine how to pass the room array into your print() function. Please read the curses reference carefully, because you will need to use functions contained in the curses library to accomplish your goal. For example, your print() function should move to location (r,c) and print the [r][c]th element of the array for each r and c within the dimensions of the room. If you have questions regarding the use of the curses library, you should ask your instructor, or execute the command man ncurses on wormulon to read the manual for the curses library. To complete this lab you must do the following: Copy the program shown above into a file named lab8.cpp. Create your function named print to print the room as described above and add it to the program. Test your program to ensure that it functions correctly.
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