To clarify, this is also a good reason to quit using arrays and pass to vectors xD
Basically you think is a 2d array[13][13], in reality that is an abstraction because the compiler see that thing as a single array[169] (which is 13*13), and the square brackets are simply handling the logic to get the right thing.
But when you do cout << &maze[0][0] , you're basically telling to cout to print an array[169] that starts at at the address of maze[0][0].
And then when you have &maze[0][1] you simply interpretas an array[169] the memory starting 1 char further compared to the previous array, and this is the reason for the inverted triangle you're printing, probably the memory after your array is filled with '\0' which is the string terminating character for C strings therefore you got:
cout << "#####\0" << endl;
cout << "####\0\0" << endl;
cout << "###\0\0\0" << endl;
cout << "##\0\0\0\0" << endl;
cout << "#\0\0\0\0\0" << endl;
Do this:
1 2 3 4 5 6 7 8
|
void outputMaze() {
for (int x = 0; x < 13; ++x) {
for (int y = 0; y < 13; ++y) {
cout << maze[x][y] << " ";
}
cout << endl;
}
}
|
Better yet, use vector xD
1 2 3 4 5 6
|
for (auto& vec : maze){
for (auto symbol : vec) {
cout << symbol << " ";
}
cout << endl;
}
|