2D Array of Pointers

This is a discussion on 2D Array of Pointers within the C++ Programming forums, part of the General Programming Boards category; I'm trying to create a two-dimensional array of pointers but I don't know how to initialize it.
What I'm trying ...

2D Array of Pointers

I'm trying to create a two-dimensional array of pointers but I don't know how to initialize it.

What I'm trying to do overall is create a text-based adventure game (like Zork). The pointers point to either strings or char arrays with the descriptions of the rooms. I was thinking of using char arrays because the names of them can be treated as pointers. So say I have the following:

The first problem is that you need the assignment operator after the subscripts to tell the compiler this is an initialization. The second is that you say a 4x4 matrix but initialize as a 5x5 matrix, change the dimensions as well:

Code:

string maparea[5][5] = {

Next, string literals and character literals are different. All occurances of '\n' should be "\n" of you will get errors. Lastly, you need commas to separate each dimension:

because it's dependant on a variable. I'm looking to base the movement on x y coordinates and tie that to the array. So when you move, the array is checked, which has links to descriptions of the rooms.

Your last example just seems to run through all of the values in the map, so that won't really work. Thanks anyway, though.

Yup, that's all my example was intended to do. But building on those examples I can now try to hook the 2D array to the map using a string from the 2D array identified by x and y. In particular I would try something like:

As an alternative to this approach I'd avoid using the map completely. This would entail using a 2D array of rooms rather than a map of rooms hooked to a 2D array of strings by way of a key that is a string.