Dear professor
I'm a first-year of secondary- schools student and I'm learning C++.
I've got an exam tomorrow. So, I'm going to ask you to do me favor and that's to give me the great pleasure of helping you. I need some guidance on how to write the following program by using the "arrays". Please guide me.

"We're in a maze and we want to cross through it safely. The user specifies two places for the program. And our program must take us from one place to the end. (another place) and we must notice that there are some dangerous monsters in some of the ways."

Thanks a lot!

Hello mojgan, thank you for the question.

This isn't too bad when you think about it. Make a char[][] that can hold the maze first off. Like this:

const int width = 20;
const int height = 2;
char maze[width][height] =
{/*find a nice ASCII images for here*/ },
{/* same as above */          }

And so forth. If you are on windows, you can open your character map and find some great ASCII symbols for a wall. Use a different ASCII symbol for an entrance and exit as well. Then when you go to draw, you can switch on the appropriate array index ASCII character symbol and perform the operations:

void draw()
for(int i = 0; i < width; i++)
for(int j = 0; j < height; j++)
case /*"ASCII WALL"*/:
// perform collision detection

And so on. So you can also throw some ASCII symbols in there to represent monsters and whatnot. See, it's not so bad.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 About.com. All rights reserved.