Multi-Dimensional Table Printing

I am trying to print an ASCII maze, but when i activate my "outputMaze" function it doesn't print out the whole maze. The table is 7 x 7 but it only prints 6 X 6.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  void outputMaze(string table[7][7]){
  int x = 0;
  int y = 0;
  while (y < 6){
    cout << table[y][x];
    if (x == 6){
      cout << endl;
      x = 0;
      y++;
    }else{
      x++;
    }
  }
}
Last edited on
I solved it some how...
In a 7-element array, the last index is 6. So, your while condition should be while(y < 7) or while(y <= 6).
Topic archived. No new replies allowed.