What's up!..
Say, for example, I want to fill a 2D array with dots '.' to later print it
as a table or as a square whatever. something like this:
...
...
...
However I wan't to put it in a function so that I can later change the Width and Length of it. I also want to be able to access it later so that I can replace a dot with another character, kind of like a game, to later make that character move
...
.C.
...
But I just don't know how to pass a 2-D array as a function parameter. This is what I have for now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
void Dungeon::createdungeon( char ar[][0], int width, int height )
{
for( int i = 0; i < height; i++ )
{
for( int j = 0; j < width; j++ )
{
ar[i][j] = '.';
}
}
}
// Then in main:
int width = 8;
int height = 16;
char dungeon_board[height][width];
Dungeon testdungeon;
testdungeon.createboard( dungeon_board, width, height );
|
If i do this, however, it won't let me pass an array I create in main, or anywhere else for that matter, to the function.
I've tried with pointers, references and nothing works!..
Alright I think that wraps it up. Thank's for taking the time, you rock!..