Hello!
Context: I am making a simple code to read in a maze from a file
the maze should look like this:
1 2 3 4 5 6
|
5 5
.S.#.
##.#.
.....
.####
....F
|
but instead, it looks like this:
1 2 3 4 5 6 7 8 9 10
|
5 5
.S.#.
##.#.
.....
.####
....F
##.#.
.....
.#
|
which causes errors later on in my code is anyone able to recognize the error from this part of my code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
//dynamically allocates array
char** mazechars = new char*[*rows+1];
for(int i = 0; i < *rows; i++){
mazechars[i] = new char[*cols];
}
//then this reads in the symbols
ifstream maze(filename);
while(!maze.eof()){
for(int i = 0; i < *rows; i++){
for(int j = 0; j < *cols; j++){
maze.get(mazechars[i][j]);
cout << mazechars[i][j];
}
}
}
|
thank you greatly
Last edited on
Thank you and also I added the code tags ty for the article