-
This is wierd.
When I run this program, it displays correctly, but it also creates a bunch of wierd ascii symbols(smilie face, etc...).
Code:
char map[9][9];
{
map[0][0] = '.';
map[1][0] = '.';
map[2][0] = '.';
map[3][0] = '.';
map[4][0] = '.';
map[5][0] = '.';
map[6][0] = '.';
map[7][0] = '.';
map[8][0] = '.';
map[9][0] = '.';
map[1][1] = '.';
map[2][1] = '.';
map[3][1] = '.';
map[4][1] = '.';
map[5][1] = '.';
map[6][1] = '.';
map[7][1] = '.';
map[8][1] = '.';
map[9][1] = '.';
map[1][2] = '.';
map[2][2] = '.';
map[3][2] = '.';
map[4][2] = '.';
map[5][2] = '.';
map[6][2] = '.';
map[7][2] = '.';
map[8][2] = '.';
map[9][2] = '.';
map[1][3] = '.';
map[2][3] = '.';
map[3][3] = '.';
map[4][3] = '.';
map[5][3] = '.';
map[6][3] = '.';
map[7][3] = '.';
map[8][3] = '.';
map[9][3] = '.';
map[1][4] = '.';
map[2][4] = '.';
map[3][4] = '.';
map[4][4] = '.';
map[5][4] = '.';
map[6][4] = '.';
map[7][4] = '.';
map[8][4] = '.';
map[9][4] = '.';
map[1][5] = '.';
map[2][5] = '.';
map[3][5] = '.';
map[4][5] = '.';
map[5][5] = '.';
map[6][5] = '.';
map[7][5] = '.';
map[8][5] = '.';
map[9][5] = '.';
map[1][6] = '.';
map[2][6] = '.';
map[3][6] = '.';
map[4][6] = '.';
map[5][6] = '.';
map[6][6] = '.';
map[7][6] = '.';
map[8][6] = '.';
map[9][6] = '.';
map[1][7] = '.';
map[2][7] = '.';
map[3][7] = '.';
map[4][7] = '.';
map[5][7] = '.';
map[6][7] = '.';
map[7][7] = '.';
map[8][7] = '.';
map[9][7] = '.';
map[1][8] = '.';
map[2][8] = '.';
map[3][8] = '.';
map[4][8] = '.';
map[5][8] = '.';
map[6][8] = '.';
map[7][8] = '.';
map[8][8] = '.';
map[9][8] = '.';
map[1][9] = '.';
map[2][9] = '.';
map[3][9] = '.';
map[4][9] = '.';
map[5][9] = '.';
map[6][9] = '.';
map[7][9] = '.';
map[8][9] = '.';
map[9][9] = '.';
}
for(mapx = 0; mapx < 10; mapx++)
{
cout << map[mapx][mapy] << endl;
for(mapy = 0; mapy < 10; mapy++)
{
cout << map[mapx][mapy];
}
}
-
>char map[9][9];
Your map is 10x10:
char map[10][10];
-
first of all map[9][0] = '.'; is wrong. You can't index into the 10th element in the array. It's only 9 big.
Second... the word is spelled W-E-I-R-D
-
Re:
I should have known(on both counts) :o
-
It would be a really good idea to initialize your matrix with a loop instead of a long string of assignment statements.
-
Or just to give you some other ideas:
Code:
char map[10][10] = {
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.',
'.','.','.','.','.','.','.','.','.','.'};
Also:
Code:
>for(mapx = 0; mapx < 10; mapx++)
>{
>cout << map[mapx][mapy] << endl; //You don't need this line. mapy isn't initialized yet.
>for(mapy = 0; mapy < 10; mapy++)
>{
>cout << map[mapx][mapy];
>}
>}
-
You could skin that cat this way too.
Code:
char map[10][10];
memset(map, '.', sizeof(map));
gg