我有一个充满全局变量的二维数组。
#define GRID_WIDTH 19
#define GRID_HEIGHT 10
char grid[GRID_WIDTH][GRID_HEIGHT];
稍后在代码中我使用这个二维数组
void Grid::ResetGrid()
{
// Empty the console screen
system("cls");
// Fills the grid with '#' walls
for (int i=0; i<GRID_WIDTH; i++)
{
for(int j = 0; j <GRID_HEIGHT; j++)
grid[i][j] = '#';
}
ir = 2;
}
当我运行程序时,我使用手表和断点。一开始,网格上的手表说:
Name: grid
Value: [0] "###################"
[0] '#'
[1] '#'
[2] '#'
//and so on, i could expand it and look at every part of the array
type: char
但现在它坏了,它只显示了这一点:
Name: grid
Value: {...}
type: Grid
奇怪的是我没有改变数组代码,只写了比较数组内部的代码行。
将其打印到控制台的代码:
void Grid::PrintGrid(int currentX, int currentY )
{
// Empty the console screen
system("cls");
// Displays the finished maze to the screen.
for (int y=0; y < GRID_HEIGHT; y++)
{
for (int x=0; x < GRID_WIDTH; x++)
{
cout << grid[x][y];
}
cout << endl;
}
// Just for testing, which direction and on what position the solver is
cout << ir << " " << currentX << "," << currentY;
}
问题是: 为什么我在手表中或当我呼啸而过时看不到二维数组中的信息?我希望你能帮助我。