I'm working on a school project that involves taking a pre-designed 25x25 maze from a .txt file and inputting it into a two dimensional array, then printing that onto the console and moving a character through the maze. The main issue I'm having is moving the characters into the array. I feel like I'm close but the code I have causes the program to crash.
Here's the loop I'm using to move the characters into the array:
int col=0;
ifstream inFile;
inFile.open("maze.txt");
char temp = inFile.get();
while(!inFile.eof())
{
for(int row=0; row<25; row++)
{
while(temp != '\n')
{
boundary[row][col] = temp;
col++;
temp=inFile.get();
}
temp=inFile.get();
}
}
inFile.close();
Essentially, the point is to move both spaces and block characters into a 25x25 character array by taking all the characters in each row into the same row of the array until it reaches a new line character, then it should move to the next character on the next row and start the while loop again.
It compiles fine, but the program crashes before it can move to any other code. If you know how to fix it without drastically changing the format I'd appreciate it because this is just a small part, but I'm open to starting from scratch if I need to.