Hello. Just need some advice on what I'm doing wrong with my code down below. I'm suppose to right up a program that reads in maze code that looks like this " 2 3swensw 2 1" for example. the first two digits = row & columns of the array while a "nested for loop" reads in the " nswe" values for each cell of the array. (n being north, s being south, e being east, and w being south.) I have completed that part of the program just fine but my problem lies with in writing a function that finds the way through the maze while outputting the path and the exit point. I've got the program to do the very first point past the starting point, which the starting point is the last two digits of that line up above.
I've been working on hours on this trying the while loop and do while loop but each time when i run the program it seems to be stuck in an endless loop.
So i started over and tried to get the program to run without outputting the pathway of each maze and the exit point. So the code down below is without the outFile << lines to make it more simple and less text.
To me this code looks like it should work fine, but for some reason the readRow and the readColumn aren't adding up to the point where they reach mazeSizeRow and mazeSizeColumn.
Note: the readRow--; and the readcolumn--; are needed because the start point of maze 1 is (1,1) which actually would be (0,0) to the array of the maze.
void TraverseMaze(char mazeArray[][Columns], int startRow, int startColumn, int mazeSizeRow, int mazeSizeColumn)
{
int readRow,
readColumn;
readRow = startRow;
readColumn = startColumn;
readRow--;
readColumn--;
do
{
if(mazeArray[readRow][readColumn]=='N')
{
readRow--;
outFile << readRow << "," << readColumn << " ";
}
else if(mazeArray[readRow][readColumn]=='S')
{
readRow++;
outFile << readRow << "," << readColumn << " ";
}
else if(mazeArray[readRow][readColumn]=='E')
{
readColumn++;
outFile << readRow << "," << readColumn << " ";
}
else if(mazeArray[readRow][readColumn]=='W')
{
readColumn--;
outFile << readRow << "," << readColumn << " ";
}
}while(readRow <= mazeSizeRow || readColumn <= mazeSizeColumn);
}